local namespace nodes

View: New views
2 Messages — Rating Filter:   Alert me  

local namespace nodes

by max toro q :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hello Michael,
Using the .NET API I'm calling
XdmNode.EnumerateAxis(XdmAxis.Namespace), which returns all the
in-scope namespaces for that element. Is there a way of getting only
the locally defined namespaces ? If no, is there a way using XPath ?

I need this info to transform the XdmNode to a different tree model,
and/or to serialize it. Right now I'm getting a lot of redundant
namespace declarations.

Thanks in advance,
--
Max

------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
saxon-help@...
https://lists.sourceforge.net/lists/listinfo/saxon-help 

Re: local namespace nodes

by Michael Kay :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


XdmNode doesn't expose this becauses there's no such concept as "locally
defined namespaces" in the XPath data model. The best you can do is to find
the namespaces that are in-scope on this element, and remove any prefix
bindings that are in-scope (and bound to the same URI) on the parent
element.

At the Saxon NodeInfo level (which underpins XdmNode), there is a method
getDeclaredNamespaces() which essentially returns the information you need,
but not in a very palatable format: it returns a list of integer namespace
codes, which can be resolved to (prefix, uri) pairs by reference to the
NamePool. (If you don't want to do this, you could perhaps still optimize
your code by using this method to detect the common case where there are no
locally-declared namespaces).

Regards,

Michael Kay
http://www.saxonica.com/
http://twitter.com/michaelhkay 

> -----Original Message-----
> From: max toro q [mailto:maxtoroq@...]
> Sent: 24 October 2009 05:28
> To: Mailing list for the SAXON XSLT and XQuery processor
> Subject: [saxon] local namespace nodes
>
> Hello Michael,
> Using the .NET API I'm calling
> XdmNode.EnumerateAxis(XdmAxis.Namespace), which returns all
> the in-scope namespaces for that element. Is there a way of
> getting only the locally defined namespaces ? If no, is there
> a way using XPath ?
>
> I need this info to transform the XdmNode to a different tree
> model, and/or to serialize it. Right now I'm getting a lot of
> redundant namespace declarations.
>
> Thanks in advance,
> --
> Max
>
> --------------------------------------------------------------
> ----------------
> Come build with us! The BlackBerry(R) Developer Conference in
> SF, CA is the only developer event you need to attend this
> year. Jumpstart your developing skills, take BlackBerry
> mobile applications to market and stay ahead of the curve.
> Join us from November 9 - 12, 2009. Register now!
> http://p.sf.net/sfu/devconference
> _______________________________________________
> saxon-help mailing list archived at
> http://saxon.markmail.org/ saxon-help@...
> https://lists.sourceforge.net/lists/listinfo/saxon-help 


------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
saxon-help@...
https://lists.sourceforge.net/lists/listinfo/saxon-help