[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

xsl:if testing elements (was: Re: Select on Text Node, XML Out of Ancestors)


Subject: xsl:if testing elements (was: Re: Select on Text Node, XML Out of Ancestors)
From: John Robert Gardner <jrgardn@xxxxxxxxx>
Date: Mon, 1 Nov 1999 20:45:45 -0500 (EST)

The template match for the xsl:if discussed on this subject bears
similarly upon what I'd asked about this morning.  Emory is having
inconceivable server problems for a university with it's funds, so I was
messed up in sending/replying sooner (and many thanks to those who had
patience with me on this, most recently Ken Holman).

The efforts of David Carlisle offlist are much appreciated, the following
script will pull all "records" wherein the PCDATA of a subfield is
0039-0310X with this XML  (apologies for not posting suitable sample code
sooner):

<root>
<record>
                <data-field tag="600" ind1="1" ind2="4">
                        <subfield code="d">1904-1984.</subfield>
                </data-field>
                <data-field tag="650" ind2="4">
                        <subfield code="a">Cognition.</subfield>
                </data-field>
                <data-field tag="773" ind1="0">
                        <subfield code="a">Studia Canonica</subfield>
                        <subfield code="x">0039-310X</subfield>
                </data-field>
        </record>
<record>
                <data-field tag="600" ind1="1" ind2="4">
                        <subfield code="d">numbers of stuff</subfield>
                </data-field>
                <data-field tag="650" ind2="4">
                        <subfield code="a">thoughts.</subfield>
                </data-field>
                <data-field tag="773" ind1="0">
                        <subfield code="a">Something</subfield>
                        <subfield code="x">0999-440X</subfield>
                </data-field>
        </record>
</root>

WIth this Stylesheet

 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
  <xsl:output type="xml" indent="yes" /> 

 <xsl:template match="root">
 <xsl:copy>
  <xsl:apply-templates mode="copy"
	select="record[data-field/subfield='0039-0310X']" /> 
  </xsl:copy>
  </xsl:template>

 <xsl:template mode="copy" match="*">
 <xsl:copy>
  <xsl:copy-of select="@*" /> 
  <xsl:apply-templates mode="copy" /> 
  </xsl:copy>
  </xsl:template>
  </xsl:stylesheet>

John Robert Gardner



 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list



Current Thread
Keywords
xml