lxinhcn / xpath-as3

Automatically exported from code.google.com/p/xpath-as3
0 stars 0 forks source link

Improved Namespace Processing #16

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
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 <link> elements in the default namespace
"//xh:link" - returns only <link> elements in the xhtml namespace
"//*:link" - returns <link> 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/">
  <updated>2008-09-26T09:37:23.51</updated>
  <title type="text">TcpConnection</title>
  <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"/>
  <id>http://10.20.8.123:8008/InfoItem/TcpConnection</id>
  <link
      href="http://10.20.8.123:8008/InfoItem/TcpConnection?&amp;pw=2"
      type="application/atom+xml"
      rel="next"/>
  <os:totalResults>594</os:totalResults>
  <os:startIndex>1</os:startIndex>
  <os:itemsPerPage>50</os:itemsPerPage>
  <os:Query startPage="1" role="request"/>
  <entry>...</entry>
</feed> 

Original issue reported on code.google.com by clintdoriot@gmail.com on 26 Sep 2008 at 3:25

GoogleCodeExporter commented 8 years ago

Original comment by peterj...@gmail.com on 4 Apr 2009 at 2:24

GoogleCodeExporter commented 8 years ago
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.

Original comment by peterj...@gmail.com on 4 Apr 2009 at 2:26

GoogleCodeExporter commented 8 years ago
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.

Original comment by peterj...@gmail.com on 11 Apr 2009 at 12:32