Subject: Re: [xsl] Looping From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx> Date: Wed, 11 Apr 2012 16:13:34 -0400 |
I'm a fairly new XSL user and am still figuring things out. Right now I'm having trouble looping through repeated elements.
Here's my source XML snippet:
<ead> ... <archdesc> ... <did> ... <langmaterial encodinganalog="546">Collection material in <language encodinganalog="041$a" langcode="eng">English</language>, <language encodinganalog="041$a" langcode="yid">Yiddish</language>, and <language encodinganalog="041$a" langcode="rus">Russian</language>. </langmaterial>
Here's my XSL snippet:
<xsl:if test="/ead/archdesc/did/langmaterial"> <xsl:for-each select="/ead/archdesc/did/langmaterial/language[1]"> <marc:datafield tag="041" ind1=" " ind2=" "> <marc:subfield code="a"> <xsl:value-of select="normalize-space(/ead/archdesc/did/langmaterial/language[1]/@langcode)" /> </marc:subfield> </marc:datafield> </xsl:for-each>
<xsl:for-each select="/ead/archdesc/did/langmaterial/language"> <marc:datafield tab="041" ind=" " ind2=" "> <marc:subfield code="a"> <xsl:value-of select="normalize-space(@langcode)"/> </marc:subfield> </mark:datafield> </xsl:for-each>
I've tried this:
<xsl:if test="/ead/archdesc/did/langmaterial">
<xsl:for-each select="/ead/archdesc/did/langmaterial/language">
<marc:datafield tag="041" ind1=" " ind2=" ">
<marc:subfield code="a">
<xsl:value-of
select="normalize-space(/ead/archdesc/did/langmaterial/language/@langcode)"
/>
</marc:subfield>
</marc:datafield>
</xsl:for-each>
</xsl:if>
But it only repeats the first @langcode three times, instead of having
three distinct outputs.
-- Public XSLT, XSL-FO, UBL and code list classes in Europe -- May 2012 Contact us for world-wide XML consulting and instructor-led training Free 5-hour lecture: http://www.CraneSoftwrights.com/links/udemy.htm Crane Softwrights Ltd. http://www.CraneSoftwrights.com/s/ G. Ken Holman mailto:gkholman@xxxxxxxxxxxxxxxxxxxx Google+ profile: https://plus.google.com/116832879756988317389/about Legal business disclaimers: http://www.CraneSoftwrights.com/legal
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] Looping, Nathan Tallman | Thread | RE: [xsl] Looping, Michele R Combs |
Re: [xsl] Unravelling Imports, G. Ken Holman | Date | RE: [xsl] Looping, Michele R Combs |
Month |