xsl-list
[Top] [All Lists]

Re: [xsl] Testing for value of a preceding "cousin"

2011-02-10 00:37:22
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(_at_)jj(_dot_)em-net(_dot_)ne(_dot_)jp> 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>Ch’en, 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>Ch’ien, 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">347–348</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 Hongō, Bunkyō-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



--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: 
<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--



--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>