[XSL-LIST Mailing List Archive Home]
[By Thread]
[By Date]
Selecting Bits, Dumping the Rest
Subject: Selecting Bits, Dumping the Rest From: John Robert Gardner <jrgardn@xxxxxxxxx> Date: Wed, 26 Apr 2000 10:18:29 -0400 (EDT) |
Perhaps what's most obvious is hardest. I've got some good string matches and position stuff going one int eh script below, but I can't get it to _only_ output those fields on which I am acting without naming each and every one of the unwanted fields. I'm trying to strip away everything other than the children/contents of fields whose @tag=773 or 001. ALl my stuff on 773 and 001 is working, but i'm getting tag-less output of all the unwanted, untemplated stuff. This xml: <?xml version="1.0"?> <marc> <record type="naa"> <control-field tag="001">ario19990010001001</control-field> <control-field tag="003">ATLA</control-field> <data-field tag="100" ind1="1"> <subfield code="a">Hull, John.</subfield> </data-field> <data-field tag="245" ind1="1" ind2="0"> <subfield code="a">Hyde, Kenneth F, 1914-1998 :</subfield> <subfield code="b">[obit]</subfield> </data-field> <data-field tag="773" ind1="0"> <subfield code="a">British Journal of Religious Education</subfield> <subfield code="g">21 (Aut 1998), p. 5-6</subfield> <subfield code="x">0141-6200</subfield> </data-field> </record> with this stylesheet: <?xml version="1.0"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:template match="/"> <xsl:apply-templates /> </xsl:template> <xsl:template match="record" > <xsl:element name="(value-of='*[@tag='001']')"> <xsl:value-of select="text()" /> <xsl:template match="*[@tag='773']/*[@code='x']"> <issn_x> <xsl:value-of select="text()" /> </issn_x> <xsl:apply-templates /> </xsl:template> <!-- this part distinguishes the first page of the article as an "foa" element --> <xsl:template match="*[@tag='773']/*[@code='g']"> <citation_g> <xsl:apply-templates select="text()" /> <xsl:variable name="ispartof" select="normalize-space(.)"/> <xsl:variable name="numseqs" select="substring-after($ispartof,'p. ')"/> <xsl:variable name="start" select="number(substring-before($numseqs,'-'))"/> <foa> <xsl:value-of select="$start" /> </foa> </citation_g> </xsl:template> </xsl:element> </xsl:template> </xsl:stylesheet> What I want to get from this utimately is: <ario19990010001001> <issn_x>0141-6200</issn_x> <citation_g>21 (Aut 1998), p. 5-6<foa>5</foa></citation_g> </ario19990010001001> -----------What is the basic principle I'm missing here? Usually it's that I _can't_ get the other stuff to come through b/c I'm screwing up with apply-templates. Now I got it backwards! Note, I do have a successful establishment of the foa element based on the variables set up. I often get an error saying I can't nest xsl:template. I can see doing a call-template, but since I can't even get the 001 field's contents to become the element type name for the element containing issn_x and citation_g, I wanted to know what I was missing. Currently, without the effort to make the 001 field contents become the wrapping element type name, I am able to get issn_x and citation_g/with foa, but I also get all the text() contents of teh unselected fields as well. Ideally, of course, I'd love to wrap issn_x and citation_g inside the 001 tag, and make the 001 tag be named the same thing as its test string contents, but then I'd just be dreaming. XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: xsl-list question, Jonathan Marsh | Thread | RE: Selecting Bits, Dumping the Res, Fox, Michael |
RE: Driving XSL based on WAP phone , Matt Sergeant | Date | Copyright symbol in FOP, scott . wright |
Month |