Namespace-ignoring case-insensitive XPath evaluation

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

Namespace-ignoring case-insensitive XPath evaluation

Peter Szinek
Hello,

I am a newbie to Saxon so sorry if i am asking some kind of
nonsense/triviality.

My problem can be described on the following example:

<bookshelf xmlns="urn:xmlns:bookshelf">
   <book genre="green">
     <titlE>The Green Book</titlE>
     <aUTHOr>Dr. Green</aUTHOr>
     <price>8.99</price>
   </book>
   <bk:BOOK genre="blue" bk:genre="deepblue"
xmlns:bk="urn:xmlns:bookshelf">
     <bk:titLe>The Blue Book</bk:titLe>
     <bk:author>Mr. Blue</bk:author>
     <bk:price>11.99</bk:price>
   </bk:BOOK>
</bookshelf>

Now, i would like the following query to return the following result:

//title:

<titlE>The Green Book</titlE>
<bk:titLe>The Blue Book</bk:titLe>

or even better would be (but this is of course a detail only, once i
have the result nodeset)

<title>The Green Book</title>
<title>The Blue Book</title>

I.e. the namespace (if there is one) is completely ignored as well as
the case of the tag (so that <bk:title> is the same as <titlE> etc)

Any help appreciated!

Thx,
peter




























-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click
_______________________________________________
saxon-help mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help
Reply | Threaded
Open this post in threaded view
|

RE: Namespace-ignoring case-insensitive XPath evaluation

Michael Kay
General XSLT coding questions (i.e. things that aren't specific to the Saxon
product) should really be directed to the xsl-list at mulberrytech.com.

You can write

//*[lower-case(local-name()) eq 'title']

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

> -----Original Message-----
> From: [hidden email]
> [mailto:[hidden email]] On Behalf Of
> Peter Szinek
> Sent: 04 January 2006 14:35
> To: [hidden email]
> Subject: [saxon] Namespace-ignoring case-insensitive XPath evaluation
>
> Hello,
>
> I am a newbie to Saxon so sorry if i am asking some kind of
> nonsense/triviality.
>
> My problem can be described on the following example:
>
> <bookshelf xmlns="urn:xmlns:bookshelf">
>    <book genre="green">
>      <titlE>The Green Book</titlE>
>      <aUTHOr>Dr. Green</aUTHOr>
>      <price>8.99</price>
>    </book>
>    <bk:BOOK genre="blue" bk:genre="deepblue"
> xmlns:bk="urn:xmlns:bookshelf">
>      <bk:titLe>The Blue Book</bk:titLe>
>      <bk:author>Mr. Blue</bk:author>
>      <bk:price>11.99</bk:price>
>    </bk:BOOK>
> </bookshelf>
>
> Now, i would like the following query to return the following result:
>
> //title:
>
> <titlE>The Green Book</titlE>
> <bk:titLe>The Blue Book</bk:titLe>
>
> or even better would be (but this is of course a detail only, once i
> have the result nodeset)
>
> <title>The Green Book</title>
> <title>The Blue Book</title>
>
> I.e. the namespace (if there is one) is completely ignored as well as
> the case of the tag (so that <bk:title> is the same as <titlE> etc)
>
> Any help appreciated!
>
> Thx,
> peter
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> -------------------------------------------------------
> This SF.net email is sponsored by: Splunk Inc. Do you grep
> through log files
> for problems?  Stop!  Download the new AJAX search engine that makes
> searching your log files as easy as surfing the  web.  
> DOWNLOAD SPLUNK!
> http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click
> _______________________________________________
> saxon-help mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/saxon-help
>




-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click
_______________________________________________
saxon-help mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help
Reply | Threaded
Open this post in threaded view
|

Re: Namespace-ignoring case-insensitive XPath evaluation

Martin Honnen-2
In reply to this post by Peter Szinek


Peter Szinek wrote:


> <bookshelf xmlns="urn:xmlns:bookshelf">
>   <book genre="green">
>     <titlE>The Green Book</titlE>

>   </book>
>   <bk:BOOK genre="blue" bk:genre="deepblue"
> xmlns:bk="urn:xmlns:bookshelf">
>     <bk:titLe>The Blue Book</bk:titLe>

> Now, i would like the following query to return the following result:
>
> //title:
>
> <titlE>The Green Book</titlE>
> <bk:titLe>The Blue Book</bk:titLe>

With XPath 2.0 that Saxon 8 implements you could use an XPath expression
  //*[lower-case(local-name()) = 'title']
I think to find all elements with local name transformed to lower case
being equal to title.


--

        Martin Honnen
        http://JavaScript.FAQTs.com/


-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click
_______________________________________________
saxon-help mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help
Reply | Threaded
Open this post in threaded view
|

Re: Namespace-ignoring case-insensitive XPath evaluation

Peter Szinek
>
>
> With XPath 2.0 that Saxon 8 implements you could use an XPath expression
>  //*[lower-case(local-name()) = 'title']
> I think to find all elements with local name transformed to lower case
> being equal to title.
>
>

Thx for your reply,

What if i want to achieve the same for an expression like

//book/title

or some more complicated XPath?

thx,
Peter



-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click
_______________________________________________
saxon-help mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help
Reply | Threaded
Open this post in threaded view
|

RE: Namespace-ignoring case-insensitive XPath evaluation

Michael Kay
> > With XPath 2.0 that Saxon 8 implements you could use an
> XPath expression
> >  //*[lower-case(local-name()) = 'title']
> > I think to find all elements with local name transformed to
> lower case
> > being equal to title.
> >
> >
>
> Thx for your reply,
>
> What if i want to achieve the same for an expression like
>
> //book/title
>
> or some more complicated XPath?
>

Just expand it:

/*[lower-case(local-name()) = 'book']/*[lower-case(local-name()) = 'title']

If you want to make it a bit more concise you can write a function

declare function f:kids($start as node(), $name as xs:string) as node()* {
  $node/*[lower-case(local-name()) = $name]
}

and then you can write

/f:kids(.,'book')/f:kids(.,'title')

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




-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click
_______________________________________________
saxon-help mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help