Resolving literal QName with a NodeInfo

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

Resolving literal QName with a NodeInfo

Florent Georges-3
  Hi,

  On the one hand, I have a NodeInfo object, representing an element.  On the other hand, I have a String object, the value of which is a lexical QName.  How can I resolve the lexical QName in the (namespace) context of the element?

  I can use iterateAxis(NAMESPACE) and parse the lexical QName myself, but I am sure there is already something doing exactly that in Saxon.

  Any tip?

  Regards,


------------------------------------------------------------------------------
Dive into the World of Parallel Programming! The Go Parallel Website,
sponsored by Intel and developed in partnership with Slashdot Media, is your
hub for all things parallel software development, from weekly thought
leadership blogs to news, videos, case studies, tutorials and more. Take a
look and join the conversation now. http://goparallel.sourceforge.net
_______________________________________________
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: Resolving literal QName with a NodeInfo

Michael Sokolov-2
There's a thing in Saxon called a NamespaceResolver; you can get it from

NamespaceResolver resolver = new InscopeNamespaceResolver(NodeInfo);

and then there seems also to be a utility for parsing QNames with that: StringToQName

cheers

-Mike

On 1/9/2015 5:20 AM, Florent Georges wrote:
  Hi,

  On the one hand, I have a NodeInfo object, representing an element.  On the other hand, I have a String object, the value of which is a lexical QName.  How can I resolve the lexical QName in the (namespace) context of the element?

  I can use iterateAxis(NAMESPACE) and parse the lexical QName myself, but I am sure there is already something doing exactly that in Saxon.

  Any tip?

  Regards,



------------------------------------------------------------------------------
Dive into the World of Parallel Programming! The Go Parallel Website,
sponsored by Intel and developed in partnership with Slashdot Media, is your
hub for all things parallel software development, from weekly thought
leadership blogs to news, videos, case studies, tutorials and more. Take a
look and join the conversation now. http://goparallel.sourceforge.net


_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help 


------------------------------------------------------------------------------
Dive into the World of Parallel Programming! The Go Parallel Website,
sponsored by Intel and developed in partnership with Slashdot Media, is your
hub for all things parallel software development, from weekly thought
leadership blogs to news, videos, case studies, tutorials and more. Take a
look and join the conversation now. http://goparallel.sourceforge.net
_______________________________________________
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: Resolving literal QName with a NodeInfo

Florent Georges-3
  Thank you, Mike!  With your information, I came up with the following:

    public QName parseQName(String value, NodeInfo scope)
            throws ToolsException
    {
        // set up the converter
        ConversionRules rules = scope.getConfiguration().getConversionRules();
        StringConverter converter = new StringConverter.StringToQName(rules);
        converter.setNamespaceResolver(new InscopeNamespaceResolver(scope));
        // convert
        ConversionResult result = converter.convertString(value);
        // check result type
        if ( ! (result instanceof QNameValue) ) {
            throw new ToolsException("Error parsing literal QName: " + result);
        }
        QNameValue qname = (QNameValue) result;
        // to generic QName
        return qname.toJaxpQName();
    }

  Now, gping to intesively test it :-)  Regards,
--
Florent Georges
http://fgeorges.org/
http://h2oconsulting.be/


Le Vendredi 9 janvier 2015 14h51, Michael Sokolov <[hidden email]> a écrit :


There's a thing in Saxon called a NamespaceResolver; you can get it from

NamespaceResolver resolver = new InscopeNamespaceResolver(NodeInfo);

and then there seems also to be a utility for parsing QNames with that: StringToQName

cheers

-Mike

On 1/9/2015 5:20 AM, Florent Georges wrote:
  Hi,

  On the one hand, I have a NodeInfo object, representing an element.  On the other hand, I have a String object, the value of which is a lexical QName.  How can I resolve the lexical QName in the (namespace) context of the element?

  I can use iterateAxis(NAMESPACE) and parse the lexical QName myself, but I am sure there is already something doing exactly that in Saxon.

  Any tip?

  Regards,



------------------------------------------------------------------------------
Dive into the World of Parallel Programming! The Go Parallel Website,
sponsored by Intel and developed in partnership with Slashdot Media, is your
hub for all things parallel software development, from weekly thought
leadership blogs to news, videos, case studies, tutorials and more. Take a
look and join the conversation now. http://goparallel.sourceforge.net


_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help 


------------------------------------------------------------------------------
Dive into the World of Parallel Programming! The Go Parallel Website,
sponsored by Intel and developed in partnership with Slashdot Media, is your
hub for all things parallel software development, from weekly thought
leadership blogs to news, videos, case studies, tutorials and more. Take a
look and join the conversation now. http://goparallel.sourceforge.net

_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help



------------------------------------------------------------------------------
Dive into the World of Parallel Programming! The Go Parallel Website,
sponsored by Intel and developed in partnership with Slashdot Media, is your
hub for all things parallel software development, from weekly thought
leadership blogs to news, videos, case studies, tutorials and more. Take a
look and join the conversation now. http://goparallel.sourceforge.net
_______________________________________________
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: Resolving literal QName with a NodeInfo

Michael Kay
I think you can cut a couple of corners here:

NamespaceResolver resolver = new InscopeNamespaceResolver(scope);
StructuredQName qName = StructuredQName.fromLexicalQName(value, true, false, resolver);
return qName.toJaxpQName()

plus some exception handling.



Michael Kay
Saxonica
[hidden email]
+44 (0) 118 946 5893




On 9 Jan 2015, at 14:41, Florent Georges <[hidden email]> wrote:

>   Thank you, Mike!  With your information, I came up with the following:
>
>     public QName parseQName(String value, NodeInfo scope)
>             throws ToolsException
>     {
>         // set up the converter
>         ConversionRules rules = scope.getConfiguration().getConversionRules();
>         StringConverter converter = new StringConverter.StringToQName(rules);
>         converter.setNamespaceResolver(new InscopeNamespaceResolver(scope));
>         // convert
>         ConversionResult result = converter.convertString(value);
>         // check result type
>         if ( ! (result instanceof QNameValue) ) {
>             throw new ToolsException("Error parsing literal QName: " + result);
>         }
>         QNameValue qname = (QNameValue) result;
>         // to generic QName
>         return qname.toJaxpQName();
>     }
>
>   Now, gping to intesively test it :-)  Regards,
> --
> Florent Georges
> http://fgeorges.org/
> http://h2oconsulting.be/
>
>
> Le Vendredi 9 janvier 2015 14h51, Michael Sokolov <[hidden email]> a écrit :
>
>
> There's a thing in Saxon called a NamespaceResolver; you can get it from
>
> NamespaceResolver resolver = new InscopeNamespaceResolver(NodeInfo);
>
> and then there seems also to be a utility for parsing QNames with that: StringToQName
>
> cheers
>
> -Mike
>
> On 1/9/2015 5:20 AM, Florent Georges wrote:
>>   Hi,
>>
>>   On the one hand, I have a NodeInfo object, representing an element.  On the other hand, I have a String object, the value of which is a lexical QName.  How can I resolve the lexical QName in the (namespace) context of the element?
>>
>>   I can use iterateAxis(NAMESPACE) and parse the lexical QName myself, but I am sure there is already something doing exactly that in Saxon.
>>
>>   Any tip?
>>
>>   Regards,
>>
>> --
>> Florent Georges
>> http://fgeorges.org/
>> http://h2oconsulting.be/
>>
>>
>>  
>>
>>
>> ------------------------------------------------------------------------------
>> Dive into the World of Parallel Programming! The Go Parallel Website,
>> sponsored by Intel and developed in partnership with Slashdot Media, is your
>> hub for all things parallel software development, from weekly thought
>> leadership blogs to news, videos, case studies, tutorials and more. Take a
>> look and join the conversation now.
>> http://goparallel.sourceforge.net
>>
>>
>> _______________________________________________
>> saxon-help mailing list archived at
>> http://saxon.markmail.org/
>> [hidden email]
>> https://lists.sourceforge.net/lists/listinfo/saxon-help 
>
>
> ------------------------------------------------------------------------------
> Dive into the World of Parallel Programming! The Go Parallel Website,
> sponsored by Intel and developed in partnership with Slashdot Media, is your
> hub for all things parallel software development, from weekly thought
> leadership blogs to news, videos, case studies, tutorials and more. Take a
> look and join the conversation now. http://goparallel.sourceforge.net
>
> _______________________________________________
> saxon-help mailing list archived at http://saxon.markmail.org/
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/saxon-help
>
>
> ------------------------------------------------------------------------------
> Dive into the World of Parallel Programming! The Go Parallel Website,
> sponsored by Intel and developed in partnership with Slashdot Media, is your
> hub for all things parallel software development, from weekly thought
> leadership blogs to news, videos, case studies, tutorials and more. Take a
> look and join the conversation now. http://goparallel.sourceforge.net_______________________________________________
> saxon-help mailing list archived at http://saxon.markmail.org/
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/saxon-help


------------------------------------------------------------------------------
Dive into the World of Parallel Programming! The Go Parallel Website,
sponsored by Intel and developed in partnership with Slashdot Media, is your
hub for all things parallel software development, from weekly thought
leadership blogs to news, videos, case studies, tutorials and more. Take a
look and join the conversation now. http://goparallel.sourceforge.net
_______________________________________________
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: Resolving literal QName with a NodeInfo

Florent Georges-3
  Works like a charm!  I knew there must be something shorter :-)

  Thank you, Mike.

--
Florent Georges
http://fgeorges.org/
http://h2oconsulting.be/


Le Vendredi 9 janvier 2015 20h06, Michael Kay <[hidden email]> a écrit :


I think you can cut a couple of corners here:

NamespaceResolver resolver = new InscopeNamespaceResolver(scope);
StructuredQName qName = StructuredQName.fromLexicalQName(value, true, false, resolver);
return qName.toJaxpQName()

plus some exception handling.



Michael Kay
Saxonica
[hidden email]
+44 (0) 118 946 5893




On 9 Jan 2015, at 14:41, Florent Georges <[hidden email]> wrote:

>  Thank you, Mike!  With your information, I came up with the following:
>
>    public QName parseQName(String value, NodeInfo scope)
>            throws ToolsException
>    {
>        // set up the converter
>        ConversionRules rules = scope.getConfiguration().getConversionRules();
>        StringConverter converter = new StringConverter.StringToQName(rules);
>        converter.setNamespaceResolver(new InscopeNamespaceResolver(scope));
>        // convert
>        ConversionResult result = converter.convertString(value);
>        // check result type
>        if ( ! (result instanceof QNameValue) ) {
>            throw new ToolsException("Error parsing literal QName: " + result);
>        }
>        QNameValue qname = (QNameValue) result;
>        // to generic QName
>        return qname.toJaxpQName();
>    }
>
>  Now, gping to intesively test it :-)  Regards,
> --
> Florent Georges
> http://fgeorges.org/
> http://h2oconsulting.be/
>
>
> Le Vendredi 9 janvier 2015 14h51, Michael Sokolov <[hidden email]> a écrit :
>
>
> There's a thing in Saxon called a NamespaceResolver; you can get it from
>
> NamespaceResolver resolver = new InscopeNamespaceResolver(NodeInfo);
>
> and then there seems also to be a utility for parsing QNames with that: StringToQName
>
> cheers
>
> -Mike
>
> On 1/9/2015 5:20 AM, Florent Georges wrote:
>>  Hi,
>>
>>  On the one hand, I have a NodeInfo object, representing an element.  On the other hand, I have a String object, the value of which is a lexical QName.  How can I resolve the lexical QName in the (namespace) context of the element?
>>
>>  I can use iterateAxis(NAMESPACE) and parse the lexical QName myself, but I am sure there is already something doing exactly that in Saxon.
>>
>>  Any tip?
>>
>>  Regards,
>>
>> --
>> Florent Georges
>> http://fgeorges.org/
>> http://h2oconsulting.be/
>>
>>
>> 
>>
>>
>> ------------------------------------------------------------------------------
>> Dive into the World of Parallel Programming! The Go Parallel Website,
>> sponsored by Intel and developed in partnership with Slashdot Media, is your
>> hub for all things parallel software development, from weekly thought
>> leadership blogs to news, videos, case studies, tutorials and more. Take a
>> look and join the conversation now.
>> http://goparallel.sourceforge.net
>>
>>
>> _______________________________________________
>> saxon-help mailing list archived at
>> http://saxon.markmail.org/
>> [hidden email]
>> https://lists.sourceforge.net/lists/listinfo/saxon-help

>
>
> ------------------------------------------------------------------------------
> Dive into the World of Parallel Programming! The Go Parallel Website,
> sponsored by Intel and developed in partnership with Slashdot Media, is your
> hub for all things parallel software development, from weekly thought
> leadership blogs to news, videos, case studies, tutorials and more. Take a
> look and join the conversation now. http://goparallel.sourceforge.net
>
> _______________________________________________
> saxon-help mailing list archived at http://saxon.markmail.org/
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/saxon-help
>
>
> ------------------------------------------------------------------------------
> Dive into the World of Parallel Programming! The Go Parallel Website,
> sponsored by Intel and developed in partnership with Slashdot Media, is your
> hub for all things parallel software development, from weekly thought
> leadership blogs to news, videos, case studies, tutorials and more. Take a
> look and join the conversation now. http://goparallel.sourceforge.net_______________________________________________
> saxon-help mailing list archived at http://saxon.markmail.org/
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/saxon-help



------------------------------------------------------------------------------
New Year. New Location. New Benefits. New Data Center in Ashburn, VA.
GigeNET is offering a free month of service with a new server in Ashburn.
Choose from 2 high performing configs, both with 100TB of bandwidth.
Higher redundancy.Lower latency.Increased capacity.Completely compliant.
http://p.sf.net/sfu/gigenet
_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help