xml - XSLT 2.0 case-insensitive matching with key() -


i'm checking existence of string in @id attribute in xml file. don't care case, letters of strings match. "myid_5" can equal "myid_5", "myid_5" , on. i'm using <xsl:key> , key(), , apparently can't use lower-case() function keys normalize @id's found key. can i? or similar?

example of xml file ($lookup-file below):

 <root>    <p id="a41_yrlydedhdr">blah</p>    <p id="a42_yrlyded15">blah</p>  </root> 

the key $lookup-file:

<xsl:key name="p-id" match="/root/p" use="@id"/> 

the template:

<xsl:template match="fig">   <xsl:variable name="id" select="lower-case(@id)"/>   <xsl:choose>     <!-- ?? can force lowercase below?? -->     <xsl:when test="exists(key('p-id', $id, $lookup-file))">       <!-- <fig> -->     </xsl:when>     <xsl:otherwise/>   </xsl:choose> </xsl:template> 

it seems collation on key might make case-insensitive, don't know collation use.

apparently can't use lower-case() function keys

why not? define key as:

<xsl:key name="p-id" match="/root/p" use="lower-case(@id)"/> 

then use as:

<xsl:when test="exists(key('p-id', lower-case(@id), $lookup-file))"> 

it seems collation on key might make case-insensitive

that's interesting idea, believe implementation processor-dependent. in saxon do:

<xsl:key name="p-id" match="/root/p" use="@id" collation="http://saxon.sf.net/collation?ignore-case=yes"/> 

http://www.saxonica.com/documentation/index.html#!extensibility/config-extend/collation/implementing-collation


Comments

Popular posts from this blog

html - Styling progress bar with inline style -

java - Oracle Sql developer error: could not install some modules -

How to use autoclose brackets in Jupyter notebook? -