Subject: RE: [xsl] can't conditionally format first occurence of a node From: jeremy <jeremy_march@xxxxxxxxxxx> Date: Sat, 25 Jun 2005 21:56:51 -0400 |
Perfect! Thanks!!! On Sun, 2005-06-26 at 04:35 +0000, Aron Bock wrote: > With this input: > > <?xml version="1.0" encoding="utf-8"?> > <TEI.2> > <text> > <body> > <entryFree> > <otherstuff1>stuff1</otherstuff1> > <otherstuff2>stuff2</otherstuff2> > <otherstuff3>stuff3</otherstuff3> > <sense n="1">blah1</sense> > <sense n="2">blah2</sense> > <sense n="3">blah3</sense> > </entryFree> > </body> > </text> > </TEI.2> > > This XSL: > > <?xml version="1.0" encoding="iso8859-1"?> > <xsl:stylesheet version="1.0" > xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> > <xsl:output method="xml" indent="yes"/> > <xsl:strip-space elements="*"/> > > <xsl:variable name="sense-1" select="//sense[position() = 1][1]"/> > <xsl:template match="node()|@*"> > <xsl:copy><xsl:apply-templates select="node()|@*"/></xsl:copy> > </xsl:template> > > <xsl:template match="sense"> > <xsl:if test="generate-id(.) = generate-id($sense-1)"> > <br/> > </xsl:if> > <xsl:copy-of select="."/> > </xsl:template> > > </xsl:stylesheet> > > Produces: > > <?xml version="1.0" encoding="UTF-8"?> > <TEI.2> > <text> > <body> > <entryFree> > <otherstuff1>stuff1</otherstuff1> > <otherstuff2>stuff2</otherstuff2> > <otherstuff3>stuff3</otherstuff3> > <br/> > <sense n="1">blah1</sense> > <sense n="2">blah2</sense> > <sense n="3">blah3</sense> > </entryFree> > </body> > </text> > </TEI.2> > > --A > > > >From: jeremy <jeremy_march@xxxxxxxxxxx> > >Reply-To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx > >To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx > >Subject: RE: [xsl] can't conditionally format first occurence of a node > >Date: Sat, 25 Jun 2005 20:12:18 -0400 > > > >Thanks for your reply. Here's an input sample and two stylesheets which > >don't quite work. > > > >Sample xml: > ><?xml version="1.0" encoding="utf-8"?> > ><TEI.2> > ><text> > ><body> > ><entryFree> > ><otherstuff1>stuff1</otherstuff1> > ><otherstuff2>stuff2</otherstuff2> > ><otherstuff3>stuff3</otherstuff3> > ><sense n="1">blah1</sense> > ><sense n="2">blah2</sense> > ><sense n="3">blah3</sense> > ></entryFree> > ></body> > ></text> > ></TEI.2> > > > > > >This stylesheet puts the <br />'s in the wrong place (not before the > >first <sense>. > > > ><xsl:stylesheet version="1.0" > >xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> > ><xsl:template match="sense"> > ><xsl:if test="position()=1"> > ><br /><br /><br /> > ></xsl:if> > ><br /><div><b><xsl:value-of select="@n"/></b>. > ><xsl:apply-templates /></div> > ></xsl:template> > ></xsl:stylesheet> > > > >This stylsheet puts the <br />'s in the right place but doesn't include > >the "otherstuff" content. > > > ><xsl:stylesheet version="1.0" > >xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> > ><xsl:template match="entryFree"> > ><xsl:apply-templates select="orth" /> > ><xsl:for-each select="sense"> > ><xsl:if test="position()=1"> > ><br /><br /><br /> > ></xsl:if> > ><br /><div><b><xsl:value-of select="@n"/></b>. > ><xsl:apply-templates /></div> > ></xsl:for-each> > ></xsl:template> > ></xsl:stylesheet> > > _________________________________________________________________ > Dont just search. Find. Check out the new MSN Search! > http://search.msn.click-url.com/go/onm00200636ave/direct/01/
Current Thread |
---|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] can't conditionally forma, Aron Bock | Thread | [xsl] XQuery, -= jay =- |
RE: [xsl] can't conditionally forma, jeremy | Date | RE: [xsl] can't conditionally forma, Aron Bock |
Month |