Hello! After we researched our problem with the XML namespaces, we came to a very tricky part in your code.
we are using the function tree.c::xmlReconciliateNs() Sample: input: <?xml version="1.0" encoding="UTF-8"?> <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"> <soapenv:Body> <ns0:OBJECT xmlns="urn:schemas-hello-com" xmlns:ns0="urn:schemas-hello-com" ns0:myValue="12345"/> </soapenv:Body> </soapenv:Envelope> current output: <?xml version="1.0" encoding="UTF-8"?> <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"> <soapenv:Body> <OBJECT xmlns="urn:schemas-hello-com" xmlns:ns0="urn:schemas-hello-com" myValue="12345"/> </soapenv:Body> </soapenv:Envelope> bug ? shouldn't it be ?: <?xml version="1.0" encoding="UTF-8"?> <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"> <soapenv:Body> <OBJECT xmlns="urn:schemas-hello-com" xmlns:ns0="urn:schemas-hello-com" ns0:myValue="12345"/> </soapenv:Body> </soapenv:Envelope> problem: after attribute myValue loses its NS prefix, the semantic of the XML changes. we think, that this is comming from here for (i = 0;i < nbCache;i++) { if (oldNs[i] == attr->ns) ) { attr->ns = newNs[i]; break; } but we have no clue how to fix this. Regards nonlandi -----Ursprüngliche Nachricht----- Von: Daniel Veillard [mailto:[EMAIL PROTECTED] Gesendet: Montag, 28. April 2008 16:24 An: Martin Landl Cc: [email protected] Betreff: Re: [xml] Problem with XML Query On Mon, Apr 28, 2008 at 03:47:06PM +0200, Martin Landl wrote: > Hi! > > I've got a problem with the following XML > <OBJECT xmlns="http://somenamespace" xmlns:ns0="http://somenamespace" myAttribute="myAttributeValue"> > <STRING xmlns="http://somenamespace" xmlns:ns1="http://somenamespace" reference="[EMAIL PROTECTED]:objname">stringvalue1</STRING> > <STRING xmlns="http://somenamespace" xmlns:ns2="http://somenamespace" reference="[EMAIL PROTECTED]:objsubject">stringvalue2</STRING> > </OBJECT> > > When I try to query the XPath "/ns1:OBJECT/@ns1:myAttribute" (having "http://somenamespace" added as "ns1") added the query returns no nodes. and that's normal. default namespace does not apply to attrbutes. The spec isn't that long, worth spending an hour or so reading it, really as it's rather important. See section 6.2 it defines it only for elements. I't confirmed in 6.3 "However, each of the following is legal, the second because the default namespace does not apply to attribute names:" http://www.w3.org/TR/REC-xml-names/ > If I change the XML "myAttribute" to "ns0:myAttribute", the same XPath query returns the attribute node properly. yes, that's normal. Daniel -- Red Hat Virtualization group http://redhat.com/virtualization/ Daniel Veillard | virtualization library http://libvirt.org/ [EMAIL PROTECTED] | libxml GNOME XML XSLT toolkit http://xmlsoft.org/ http://veillard.com/ | Rpmfind RPM search engine http://rpmfind.net/ _______________________________________________ xml mailing list, project page http://xmlsoft.org/ [email protected] http://mail.gnome.org/mailman/listinfo/xml
