More XPath

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

More XPath

Leon Bezuidenhout
Hi,

I have a n XMLDocument containing the following XML:

<root>
 <r rn="90">
  <f1>WILMK</f1>
  <f2>Wilman%20Kala</f2>
 </r>
 <r rn="91">
  <f1>WOLZA</f1>
  <f2>Wolski%20%20Zajazd</f2>
 </r>
 <DSODetails>
  <LastErrorCode>0</LastErrorCode>
  <BOF>1</BOF>
  <EOF>1</EOF>
 </DSODetails>
</root>

When I exucute
var aItems = document.evaluate("//r", xNode, oNSResolver,
XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);

Then aItem.length = 2

But when I execute
var aItems = document.evaluate("//DSODetails", xNode, oNSResolver,
XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
Then aItem.length = 0

Is this a bug? It works fine if I lowercase all the tag names. The project I
am working on is an ex IE project and going back to change all the XML tags
to lower case is not an option. It will mean having to change thousand of
client side scripts that generate XML.

Is there a work around for this problem?

Thanks,
Leon


_______________________________________________
dev-tech-xml mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-tech-xml
Reply | Threaded
Open this post in threaded view
|

Re: More XPath

Martin Honnen-3
Leon Bezuidenhout wrote:

> But when I execute
> var aItems = document.evaluate("//DSODetails", xNode, oNSResolver,
> XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
> Then aItem.length = 0
>
> Is this a bug?

Here is a complete test case
<http://home.arcor.de/martin.honnen/javascript/2006/12/test2006122101.html>
shows 1 for me not 0 with both SeaMonkey 1.0 and Firefox 2.0. Please
provide a minimal test case and tell us exactly which version of Mozilla
you think has a bug.

And you have already been warned that Mozilla does not support XML data
islands, if you are silly enough to feed innerHTML to an XML parser then
it is not a bug in Mozilla if case of element names is lost. You need to
load and parse XML markup with Mozilla's XML parser and not with its
HTML parser.


--

        Martin Honnen
        http://JavaScript.FAQTs.com/
_______________________________________________
dev-tech-xml mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-tech-xml
Reply | Threaded
Open this post in threaded view
|

Re: More XPath

Jonas Sicking
In reply to this post by Leon Bezuidenhout
Like Martin pointed out, your problem is most likely not in the XPath,
but in your handling of markups. Don't put XML inside HTML and expect it
to work. The HTML parser will apply all 10 years of web compatibility
quirks handling on the DOM and so lots of things might happen to it that
you don't expect.

Have you looked at the DOM using the DOM-Inspector? Does it look like
what you think it does?

If you want to pass XML along with your HTML then put it inside a
comment or inside a javascript variable and then parse it using
DOMParser. Don't put it right inside the markup since that's both more
wasteful processing-wise (first parsed as HTML and then serialized back
to a string), and exposes it to all the quirks of HTML parsing.

/ Jonas
_______________________________________________
dev-tech-xml mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-tech-xml
Reply | Threaded
Open this post in threaded view
|

Re: More XPath

Leon Bezuidenhout
Hi,

Sorry, I was not very clear on what I was doing. This data is not in an XML
island, it is retrieved with an HTTPRequest. I am using MOZ 2.0

Thanks


"Jonas Sicking" <[hidden email]> wrote in message
news:[hidden email]...

> Like Martin pointed out, your problem is most likely not in the XPath, but
> in your handling of markups. Don't put XML inside HTML and expect it to
> work. The HTML parser will apply all 10 years of web compatibility quirks
> handling on the DOM and so lots of things might happen to it that you
> don't expect.
>
> Have you looked at the DOM using the DOM-Inspector? Does it look like what
> you think it does?
>
> If you want to pass XML along with your HTML then put it inside a comment
> or inside a javascript variable and then parse it using DOMParser. Don't
> put it right inside the markup since that's both more wasteful
> processing-wise (first parsed as HTML and then serialized back to a
> string), and exposes it to all the quirks of HTML parsing.
>
> / Jonas


_______________________________________________
dev-tech-xml mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-tech-xml
Reply | Threaded
Open this post in threaded view
|

Re: More XPath

Martin Honnen-3
Leon Bezuidenhout wrote:

> Sorry, I was not very clear on what I was doing. This data is not in an XML
> island, it is retrieved with an HTTPRequest. I am using MOZ 2.0

Test case
<http://home.arcor.de/martin.honnen/javascript/2006/12/test2006122201.html>
works for me with Firefox 2.0 and SeaMonkey 1.0.


--

        Martin Honnen
        http://JavaScript.FAQTs.com/
_______________________________________________
dev-tech-xml mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-tech-xml
Reply | Threaded
Open this post in threaded view
|

Re: More XPath

Leon Bezuidenhout
Thanks,

I see yours working and yet mine still does not work, which makes me wonder
about the document encoding... Oh well, I have a dirty work around in the
mean time.

"Martin Honnen" <[hidden email]> wrote in message
news:[hidden email]...

> Leon Bezuidenhout wrote:
>
>> Sorry, I was not very clear on what I was doing. This data is not in an
>> XML island, it is retrieved with an HTTPRequest. I am using MOZ 2.0
>
> Test case
> <http://home.arcor.de/martin.honnen/javascript/2006/12/test2006122201.html>
> works for me with Firefox 2.0 and SeaMonkey 1.0.
>
>
> --
>
> Martin Honnen
> http://JavaScript.FAQTs.com/ 


_______________________________________________
dev-tech-xml mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-tech-xml
Reply | Threaded
Open this post in threaded view
|

Re: More XPath

Jonas Sicking
It's probably not an encoding issue but rather a content-type issue. You
are sending your xml as text/xml or application/xml, right? How are you
getting this data from XMLHttpRequest? Using .responseXML ?

Most likely the problem is on your end rather than in mozilla so if it's
important I'm sure normal debugging will find the issue for you.

/ Jonas

Leon Bezuidenhout wrote:

> Thanks,
>
> I see yours working and yet mine still does not work, which makes me wonder
> about the document encoding... Oh well, I have a dirty work around in the
> mean time.
>
> "Martin Honnen" <[hidden email]> wrote in message
> news:[hidden email]...
>> Leon Bezuidenhout wrote:
>>
>>> Sorry, I was not very clear on what I was doing. This data is not in an
>>> XML island, it is retrieved with an HTTPRequest. I am using MOZ 2.0
>> Test case
>> <http://home.arcor.de/martin.honnen/javascript/2006/12/test2006122201.html>
>> works for me with Firefox 2.0 and SeaMonkey 1.0.
>>
>>
>> --
>>
>> Martin Honnen
>> http://JavaScript.FAQTs.com/ 
>
>
_______________________________________________
dev-tech-xml mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-tech-xml
Reply | Threaded
Open this post in threaded view
|

Re: More XPath

Leon Bezuidenhout
Thanks, I reckon you are right.I get my data using XMLHttpRequest and I
suspect the MIME type is set to text/html



"Jonas Sicking" <[hidden email]> wrote in message
news:[hidden email]...

> It's probably not an encoding issue but rather a content-type issue. You
> are sending your xml as text/xml or application/xml, right? How are you
> getting this data from XMLHttpRequest? Using .responseXML ?
>
> Most likely the problem is on your end rather than in mozilla so if it's
> important I'm sure normal debugging will find the issue for you.
>
> / Jonas
>
> Leon Bezuidenhout wrote:
>> Thanks,
>>
>> I see yours working and yet mine still does not work, which makes me
>> wonder about the document encoding... Oh well, I have a dirty work around
>> in the mean time.
>>
>> "Martin Honnen" <[hidden email]> wrote in message
>> news:[hidden email]...
>>> Leon Bezuidenhout wrote:
>>>
>>>> Sorry, I was not very clear on what I was doing. This data is not in an
>>>> XML island, it is retrieved with an HTTPRequest. I am using MOZ 2.0
>>> Test case
>>> <http://home.arcor.de/martin.honnen/javascript/2006/12/test2006122201.html>
>>> works for me with Firefox 2.0 and SeaMonkey 1.0.
>>>
>>>
>>> --
>>>
>>> Martin Honnen
>>> http://JavaScript.FAQTs.com/
>>

_______________________________________________
dev-tech-xml mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-tech-xml