Thank you to everyone who answered my question yesterday. I’m glad to know that 
“./.” is the same as “.” except that the longer version will throw an error if 
the context item is not a node. Since we are teaching beginners, I’m going to 
suggest to my colleague that we use the shorter version “.” in the example.

Also, sorry I wrote to the XQuery list for an XSLT question. I’m just not 
subscribed to an XSLT list, but really should be. After years of using XQuery 
as my “hammer” I’m starting to use XSLT more when appropriate.

Best,

Chris


Christine Schwartz
Metadata Librarian and XML Database Administrator
Princeton Theological Seminary Library




From: W.S. Hager [mailto:wsha...@gmail.com]
Sent: Monday, October 31, 2016 6:12 PM
To: Michael Kay <m...@saxonica.com>
Cc: Schwartz, Christine <christine.schwa...@ptsem.edu>; talk@x-query.com
Subject: Re: [xquery-talk] Unusual XPath syntax question


I just love to do .[1][1][1][1][1][1][1]

Op 31 okt. 2016 19:19 schreef "Michael Kay" 
<m...@saxonica.com<mailto:m...@saxonica.com>>:
I agree with the other respondents: apart from giving an error if the context 
item is not a node, "./." is precisely equivalent to ".".

(Not sure why an XSLT question is appearing on the XQuery list...)

There's a certain fondness for verbosity in some parts of the XSLT user 
community. It's quite common to see "./price" where "price" would serve 
perfectly well, or "price/text()" for "price"; or xsl:element and xsl:attribute 
used where literal result elements would do the job, or (my favourite gripe)

<xsl:variable name="x">
  <xsl:value-of select="count(y)"/>
</xsl:variable>

where <xsl:variable name="x" select="count(y)"/> would serve the purpose better.

And of course we've all seen things like <xsl:if test="contains(x, y) = 
true()">.

I think some XSLT programmers must be paid by the yard; alternatively the 
language attracts those who love the sourd of their own keyboard. But "./." 
isn't an expansion I have seen before.

Michael Kay
Saxonica

> On 31 Oct 2016, at 16:52, Schwartz, Christine 
> <christine.schwa...@ptsem.edu<mailto:christine.schwa...@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'<mailto:./@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.schwa...@ptsem.edu<mailto:christine.schwa...@ptsem.edu>
> (609) 497-7938
>
>
>
> _______________________________________________
> talk@x-query.com<mailto:talk@x-query.com>
> http://x-query.com/mailman/listinfo/talk



_______________________________________________
talk@x-query.com<mailto:talk@x-query.com>
http://x-query.com/mailman/listinfo/talk
_______________________________________________
talk@x-query.com
http://x-query.com/mailman/listinfo/talk

Reply via email to