Getting namespace mapping from axisIterator(Axis.NAMESPACE)

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

Getting namespace mapping from axisIterator(Axis.NAMESPACE)

cmarchand
Hello !

I'm looking for a way to get de fined namespace mapping via s9api : I've
tried this, but ns.getPrefix() and ns.getURI() are always empty. I need
to get the prefix and the URI to define a NamespaceMApping I could
re-use elsewhere.

                 XdmSequenceIterator it =
element.axisIterator(Axis.NAMESPACE);
                 while(it.hasNext()) {
                     XdmNode item = (XdmNode)(it.next());
                     NamespaceNode ns =
(NamespaceNode)(item.getUnderlyingNode());
                     pv.defineNamespace(ns.getPrefix(), ns.getURI());
                     LOGGER.debug("namespaces : "+ns.getPrefix()+" ->
"+ns.getURI());
                 }

I've search the list archive, but didn't find any relevant thread.

Any help will be much appreciated.

Best,
Christophe


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help 
Reply | Threaded
Open this post in threaded view
|

Re: Getting namespace mapping from axisIterator(Axis.NAMESPACE)

Michael Kay
The name of a namespace node is a QName with null prefix and URI. To get the namespace prefix, you want the local name of the node, and to get the URI, you want the string value of the node. (You can also get these directly from the XdmNode, without dropping down to the underlying NamespaceNode).

Michael Kay
Saxonica


> On 19 May 2017, at 08:07, Christophe Marchand <[hidden email]> wrote:
>
> Hello !
>
> I'm looking for a way to get de fined namespace mapping via s9api : I've
> tried this, but ns.getPrefix() and ns.getURI() are always empty. I need
> to get the prefix and the URI to define a NamespaceMApping I could
> re-use elsewhere.
>
>                 XdmSequenceIterator it =
> element.axisIterator(Axis.NAMESPACE);
>                 while(it.hasNext()) {
>                     XdmNode item = (XdmNode)(it.next());
>                     NamespaceNode ns =
> (NamespaceNode)(item.getUnderlyingNode());
>                     pv.defineNamespace(ns.getPrefix(), ns.getURI());
>                     LOGGER.debug("namespaces : "+ns.getPrefix()+" ->
> "+ns.getURI());
>                 }
>
> I've search the list archive, but didn't find any relevant thread.
>
> Any help will be much appreciated.
>
> Best,
> Christophe
>
>
> ------------------------------------------------------------------------------
> Check out the vibrant tech community on one of the world's most
> engaging tech sites, Slashdot.org! http://sdm.link/slashdot
> _______________________________________________
> saxon-help mailing list archived at http://saxon.markmail.org/
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/saxon-help 


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help 
Reply | Threaded
Open this post in threaded view
|

Re: Getting namespace mapping from axisIterator(Axis.NAMESPACE)

cmarchand
Thanks a lot Michael, it works perfectly.

Best regards,
Christophe


Le 19/05/2017 à 10:02, Michael Kay a écrit :

> The name of a namespace node is a QName with null prefix and URI. To get the namespace prefix, you want the local name of the node, and to get the URI, you want the string value of the node. (You can also get these directly from the XdmNode, without dropping down to the underlying NamespaceNode).
>
> Michael Kay
> Saxonica
>
>
>> On 19 May 2017, at 08:07, Christophe Marchand <[hidden email]> wrote:
>>
>> Hello !
>>
>> I'm looking for a way to get de fined namespace mapping via s9api : I've
>> tried this, but ns.getPrefix() and ns.getURI() are always empty. I need
>> to get the prefix and the URI to define a NamespaceMApping I could
>> re-use elsewhere.
>>
>>                  XdmSequenceIterator it =
>> element.axisIterator(Axis.NAMESPACE);
>>                  while(it.hasNext()) {
>>                      XdmNode item = (XdmNode)(it.next());
>>                      NamespaceNode ns =
>> (NamespaceNode)(item.getUnderlyingNode());
>>                      pv.defineNamespace(ns.getPrefix(), ns.getURI());
>>                      LOGGER.debug("namespaces : "+ns.getPrefix()+" ->
>> "+ns.getURI());
>>                  }
>>
>> I've search the list archive, but didn't find any relevant thread.
>>
>> Any help will be much appreciated.
>>
>> Best,
>> Christophe
>>
>>
>> ------------------------------------------------------------------------------
>> Check out the vibrant tech community on one of the world's most
>> engaging tech sites, Slashdot.org! http://sdm.link/slashdot
>> _______________________________________________
>> saxon-help mailing list archived at http://saxon.markmail.org/
>> [hidden email]
>> https://lists.sourceforge.net/lists/listinfo/saxon-help
>
> ------------------------------------------------------------------------------
> Check out the vibrant tech community on one of the world's most
> engaging tech sites, Slashdot.org! http://sdm.link/slashdot
> _______________________________________________
> saxon-help mailing list archived at http://saxon.markmail.org/
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/saxon-help
>


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help