haysclark / as3-xpath

1 stars 0 forks source link

Improved Namespace Processing #16

Closed haysclark closed 10 years ago

haysclark commented 10 years ago

From clintdoriot@gmail.com on September 26, 2008 08:25:46

The library should automatically handle adding namespaces to the xpath context (at least as an option), including the use of a default namespace.

The following xpath queries should work: "//link" - returns only elements in the default namespace "//xh:link" - returns only elements in the xhtml namespace "//*:link" - returns elements from any namespace

(As of xpath-as3 1.0, these namespaces must be set in an xpath context manually, and there is no default namespace)

<feed xmlns=" http://www.w3.org/2005/Atom " xmlns:xh=" http://www.w3.org/1999/xhtml " xmlns:os=" http://a9.com/-/spec/opensearch/1.1/ ">

2008-09-26T09:37:23.51 TcpConnection

<link href="http://10.20.8.123:8008/InfoItem/TcpConnection type="application/atom+xml" rel="self"/> <link href="/opensearchdescription.xml" type="application/opensearchdescription+xml" rel="search"/>

http://10.20.8.123:8008/InfoItem/TcpConnection

<link href="http://10.20.8.123:8008/InfoItem/TcpConnection?&amp;pw=2 type="application/atom+xml" rel="next"/> os:totalResults594/os:totalResults os:startIndex1/os:startIndex os:itemsPerPage50/os:itemsPerPage

...

Original issue: http://code.google.com/p/xpath-as3/issues/detail?id=16

haysclark commented 10 years ago

From peterj...@gmail.com on April 04, 2009 07:24:33

Status: Accepted
Owner: peterjoel
Labels: -Type-Defect Type-Enhancement

haysclark commented 10 years ago

From peterj...@gmail.com on April 04, 2009 07:26:47

There is already a property XPathContext.openAllNamespaces, which does a part of this.

In the version of the flash player that was current when this library was written, there was a problem with XML in AS3 where it renamed namespace prefixes internally. It meant you couldn't reliably get the original prefix, nor you tell which is the default namespace (ie no prefix).

Since then, it seems to behave better, but I haven't had that officially confirmed, and I don't know exactly in which version of the Flash Player this can be depended upon.

So I'm going to look into this and see if we can do something.

haysclark commented 10 years ago

From peterj...@gmail.com on April 11, 2009 05:32:53

I've added a flag, XPathContext.useSourceNamespacePrefixes, which defaults to false. Setting it to true will activate the feature and cause the source prefixes (and default namespaces) to be available to XPath.

This will require some testing still. I've put a request in the forum for feedback also on the choice of name and default value.

Status: Fixed