[xquery-talk] Unusual XPath syntax question

Ghislain Fourny ghislain.fourny at gmail.com
Mon Oct 31 10:12:56 PDT 2016


Hi Christine,

In principle, in XPath, "./." is the same as "." and returns the context item. There is a minor difference, in that "./." will return an error if the context item is not a node, but in the case of the query at hand, it should always be an element node. Replacing "./." with "." produced the same results on my side.

I'd definitely wait for Mike's answer before concluding on this though, because he'll probably see something I haven't. :-)

Kind regards,
Ghislain


> On 31 Oct 2016, at 17:52, Schwartz, Christine <christine.schwartz at ptsem.edu> wrote:
> 
> Hi,
> 
> I'm hoping someone on this list can clarify my conundrum.
> 
> I'm working with a colleague on a writing project and one of his examples uses this XPath syntax "./." in the starts-with() function within an XSLT stylesheet. I don't know what "./." means. I would think that "." alone would be sufficient to refer to the context node.
> 
> Here's the example: 
> 
> <xsl:for-each select="//dim:field">
>    <xsl:if test="./@element='title'">
> 	<xsl:choose>
> 	   <xsl:when test="starts-with(./.,'The ')">
> 		 <datafield tag="245" ind1="1" ind2="4">
> 			<subfield code="a"><xsl:value-of select="."/>.</subfield>
> 		 </datafield>
> 	   </xsl:when>
> 	   <xsl:when test="starts-with(./.,'An ')">
> 		 <datafield tag="245" ind1="1" ind2="3">
> 			<subfield code="a"><xsl:value-of select="."/>.</subfield>
> 		 </datafield>
> 	   </xsl:when>
> 	   <xsl:when test="starts-with(./.,'A ')">
> 		 <datafield tag="245" ind1="1" ind2="2">
> 			<subfield code="a"><xsl:value-of select="."/>.</subfield>
> 		 </datafield>
> 	   </xsl:when>
> 	   <xsl:otherwise>
> 	        <datafield tag="245" ind1="1" ind2="0">
> 		      <subfield code="a"><xsl:value-of select="."/>.</subfield>
> 	        </datafield>
> Thanks, 
> 
> Chris
> 
> Christine Schwartz
> Metadata Librarian and XML Database Administrator
> Princeton Theological Seminary
> Library
> P.O. Box 821
> Princeton, NJ 08542
> christine.schwartz at ptsem.edu
> (609) 497-7938
> 
> 
> 
> _______________________________________________
> talk at x-query.com
> http://x-query.com/mailman/listinfo/talk







More information about the talk mailing list