sanand0 / xmljson

xmlsjon converts XML into Python dictionary structures (trees, like in JSON) and vice-versa.
MIT License
121 stars 33 forks source link

XML namespaces #8

Closed Charnelx closed 7 years ago

Charnelx commented 7 years ago

Hi.

Does this module actually have namespaces support?

For example i have such XML file with custom namespace prefix v8msg:

<?xml version="1.0" encoding="UTF-8"?>
<v8msg:Message xmlns:v8msg="http://v8.1c.ru/messages">
  <v8msg:Header>
    <v8msg:ExchangePlan>МобТорговля</v8msg:ExchangePlan>
    <v8msg:To>Моб1</v8msg:To>
    <v8msg:From>ЦУ</v8msg:From>
    <v8msg:MessageNo>83</v8msg:MessageNo>
    <v8msg:ReceivedNo>0</v8msg:ReceivedNo>
  </v8msg:Header>
  <v8msg:Body>
    <CatalogObject.ТипыЦенНоменклатуры>
      <Ref>ec986086-5ba8-11e4-ae81-74f06d6aab21</Ref>
      <DeletionMark>false</DeletionMark>
      <Code>000000001</Code>
      <Description>Роздріб</Description>
    </CatalogObject.ТипыЦенНоменклатуры>
  </v8msg:Body>
</v8msg:Message>

After conversion XML - to - JSON and backwards i get this:

<?xml version="1.0" encoding="UTF-8"?>
<ns0:Message xmlns:ns0="http://v8.1c.ru/messages>
  <ns0:Header>
    <ns0:ExchangePlan>МобТорговля</v8msg:ExchangePlan>
    <ns0:To>Моб1</v8msg:To>
    <ns0:From>ЦУ</v8msg:From>
    <ns0:MessageNo>83</v8msg:MessageNo>
    <ns0:ReceivedNo>0</v8msg:ReceivedNo>
  </ns0:Header>
  <ns0:Body>
    <CatalogObject.ТипыЦенНоменклатуры>
      <Ref>ec986086-5ba8-11e4-ae81-74f06d6aab21</Ref>
      <DeletionMark>false</DeletionMark>
      <Code>000000001</Code>
      <Description>Роздріб</Description>
    </CatalogObject.ТипыЦенНоменклатуры>
  </ns0:Body>
</ns0:Message>

So is there any way to preserve real prefix for namespaces?

sanand0 commented 7 years ago

@Charnelx I'm afraid the repository does not currently support namespaces. I'd be happy to review any pull requests that implement the functionality, though.

Charnelx commented 7 years ago

@sanand0 I'm workig on this. My implementation almost ready, hope sone I'll make pull quest.

sanand0 commented 7 years ago

@Charnelx just checking if you had any luck with the namespace implementation?

sanand0 commented 7 years ago

Closing in favour of https://github.com/sanand0/xmljson/pull/9