doc.xml(force_nsdecls=xmlcreation.vinoxml_NSS)

5 views
Skip to first unread message

Werner

unread,
Feb 17, 2013, 2:34:24 AM2/17/13
to ak...@googlegroups.com
Hi Uche and Luis Miguel,

I start a new thread instead continuing on the old one.

I have it resolved by changing my createXMLQuery to this:

def createXMLquery():
"""
Create a bindery instance, to be used for e.g. GWS vinoXML query"""
doc_header = """<query
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://www.vinoxml.org/XMLschema"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"></query>"""

doc = xmlu.bindery.parse(doc_header)

return doc

That gives me the name spaces as Global Wine Stocks (GWS) wants/expects
them, so much easier/nicer then the "force_nsdecls".

Only "hick" is that I still need to remove 'xmlns=""' from the string:

docString = doc.xml_encode()
qs = docString.replace('xmlns=""', '')

Otherwise GWS gives me a "Query not well formed" error.

My question, is the GWS XML parser not standard compliant or ...?

Werner

Uche Ogbuji

unread,
Feb 18, 2013, 1:40:14 AM2/18/13
to ak...@googlegroups.com
On Sun, Feb 17, 2013 at 12:34 AM, Werner <werner...@sfr.fr> wrote:
Hi Uche and Luis Miguel,

I start a new thread instead continuing on the old one.

I have it resolved by changing my createXMLQuery to this:

def createXMLquery():
    """
    Create a bindery instance, to be used for e.g. GWS vinoXML query"""
    doc_header = """<query xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.vinoxml.org/XMLschema" xmlns:xsd="http://www.w3.org/2001/XMLSchema"></query>"""

    doc = xmlu.bindery.parse(doc_header)

    return doc

That gives me the name spaces as Global Wine Stocks (GWS) wants/expects them, so much easier/nicer then the "force_nsdecls".

Yep, this works.  You can also create namespace declarations:

elem.xmlns_attributes[prefix] = uri


Only "hick" is that I still need to remove 'xmlns=""' from the string:

        docString = doc.xml_encode()
        qs = docString.replace('xmlns=""', '')

Otherwise GWS gives me a "Query not well formed" error.

My question, is the GWS XML parser not standard compliant or ...?

Are you creating elements in the document which are not in the http://www.vinoxml.org/XMLschema NS?  That's the only thing I can think of that would lead to sprinkling of 'xmlns=""'.

BTW working with MicroXML makes me wonder how I tolerated namespaces for so long!


--
Uche Ogbuji                       http://uche.ogbuji.net
Founding Partner, Zepheira        http://zepheira.com
http://wearekin.org
http://www.thenervousbreakdown.com/author/uogbuji/
http://copia.ogbuji.net
http://www.linkedin.com/in/ucheogbuji
http://twitter.com/uogbuji

Werner

unread,
Feb 18, 2013, 6:44:30 AM2/18/13
to ak...@googlegroups.com
On 18/02/2013 07:40, Uche Ogbuji wrote:
On Sun, Feb 17, 2013 at 12:34 AM, Werner <werner...@sfr.fr> wrote:
...

My question, is the GWS XML parser not standard compliant or ...?

Are you creating elements in the document which are not in the http://www.vinoxml.org/XMLschema NS?  That's the only thing I can think of that would lead to sprinkling of 'xmlns=""'.
No, or at least not that I am aware off.  Did a small test and don't have it in there, so will do some more testing and see why it shows up in the app.

Will get back on findings.

Werner
Reply all
Reply to author
Forward
0 new messages