Subject: Re: [xsl] Testing for value of a preceding "cousin" From: Brandon Ibach <brandon.ibach@xxxxxxxxxxxxxxxxxxx> Date: Thu, 10 Feb 2011 01:37:11 -0500 |
You need to use the ancestor axis to look up the tree, rather than searching from the root down, which will always return true, as long as there's a journal title somewhere in the document. Also, it may have just been a typo in your example, but you were missing the "@" before "level". <xsl:when test="ancestor::monogr[1]/title[@level='j']">...</xsl:when> -Brandon :) On Thu, Feb 10, 2011 at 12:55 AM, Charles Muller <cmuller-lst@xxxxxxxxxxxxxxx> wrote: > When applying styles to the <date> element within in a TEI <biblStruct> > ancestor, such as the following > > <biblStruct xml:id="Chen-1964"><monogr><author>Chben, Kenneth</author><title > level="m">Buddhism in China: A Historical > Survey</title><imprint><pubPlace>Princeton</pubPlace><publisher>Princeton > University > Press</publisher><date>1964</date></imprint></monogr></biblStruct> > > I have, for several years, been using the following simple XSLT, > > <xsl:template match="date"> > <xsl:if test="(parent::p)"> > <xsl:apply-templates/> > </xsl:if> > <xsl:apply-templates/>. > </xsl:template> > > Thus, in the case of the above, the output would simply be the date, > followed by a period. > > In the present manuscript that I am working on, the publisher asks that > journal dates be placed in parentheses. > > Thus, for example, in the following entry > > <biblStruct xml:id="Chien-1988"><analytic><author>Chbien, Edward > T.</author><title level="a">The Neo-Confucian Confrontation with Buddhism: A > Structural and Historical Analysis</title></analytic><monogr><title > level="j">Journal of Chinese Philosophy</title><imprint><biblScope > type="vol">15</biblScope><date>1988</date><biblScope > type="pp">347b348</biblScope></imprint> </monogr></biblStruct> > > ...since we have <title level="j"> (indicating a journal), I would like the > output to be (1988). I know how to test for attribute values in the case of > a preceding node, or a sibling, or parent, or ancestor. But in this case, > the <title level="j"> element is none of these, although it has the same > ancestor. I attempted to deal with this by testing for the existence of a > <title level="j"> under the same ancestor of <monogr> > > <xsl:template match="date"> > <xsl:choose> > <xsl:when test="(parent::p)"> > <xsl:apply-templates/> > </xsl:when> > <xsl:when test="//monogr/title[level='j']"> > (<xsl:apply-templates/>) > </xsl:when> > <xsl:otherwise> > <xsl:apply-templates/>. > </xsl:otherwise> > </xsl:choose> > </xsl:template> > > > But so far no luck. I was going to try the route of creating a variable when > level="j" exists, but I thought that I should ask here to see if there is a > way of doing it with standard axes methods. > > Chuck > > > ------------------- > > A. Charles Muller > > University of Tokyo > Graduate School of Humanities and Sociology, Faculty of Letters > Center for Evolving Humanities > 7-3-1 HongE , BunkyE -ku > Tokyo 113-0033, Japan > > Web Site: Resources for East Asian Language and Thought > http://www.acmuller.net > > <acmuller[at]jj.em-net.ne.jp> > > Mobile Phone: 090-9310-1787
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] Testing for value of a preced, Charles Muller | Thread | Re: [xsl] Testing for value of a pr, Charles Muller |
[xsl] Testing for value of a preced, Charles Muller | Date | Re: [xsl] 1st previous node(), Karl Stubsjoen |
Month |