Subject: Re: [xsl] using name() to generate a tag dynamically in xsl output - STILL TRYING From: mark bordelon <markcbordelon@xxxxxxxxx> Date: Fri, 26 Feb 2010 13:35:44 -0800 (PST) |
Chris, 1000 pardons. Your solution does work. I implemented it incorrectly at first. Thank you! Mark --- On Fri, 2/26/10, mark bordelon <markcbordelon@xxxxxxxxx> wrote: > From: mark bordelon <markcbordelon@xxxxxxxxx> > Subject: Re: [xsl] using name() to generate a tag dynamically in xsl output - STILL TRYING > To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx > Date: Friday, February 26, 2010, 1:24 PM > I was not clear. And I should have > posted some xml, so here it is: > > <text> > B B B <line id="1" s_len="2.8"> > B B B <word id="1">Thou</word> > B B B <word id="2">still</word> > B B B <word > id="3">unravish'd</word> > B B B <word id="4">bride</word> > B B B <word id="5">of</word> > B B B <word > id="6">quietness</word>, > B B B </line> > B B B <clause id="2" s_len="2.4"> > B B B <word id="7">The</word> > B B B <word > id="8">quick</word>- > B B B <word id="9">brown</word> > B B B <word id="10">fox</word> > B B B <word > id="11">jumped</word> > B B B <word id="12">over</word> > B B B <word id="13">lazy</word> > B B B <word id="14">dog</word>, > B B </clause> > </text> > > I want a the xpath which would work in a template match to > get the parent node of <word>, no matter what it is, > whose @s_len attribute is less than 2.5 seconds. > > The template will then compose an element for output, using > the tagname of that parent of <word> which met that > condition. > > This works: > <xsl:template match="clause[@s_len<2.5] | > line[@s_len<2.5]"> > <xsl:element name="{name()}"> > B B B <xsl:attribute > name="id"><xsl:value-of select="@id" > /></xsl:attribute> > </xsl:element> > </xsl:template> > > But it presumes that I know that the parent of <word> > is either a node named <clause> or <line>. I am > trying to generalize even further and not make that > assumption in the match condition. > > As I said, I cannot seem to use any axis or axis-like > expression, so matches like the following give an error in > Altova Spy: > match="word/parent::*[@s_len<2.5]" > match="word/../*[@s_len<2.5]" > > I have tried your suggestions and no node is returned, but > I think I was not clear in what I needed. > > > --- On Fri, 2/26/10, Christopher R. Maden <crism@xxxxxxxxx> > wrote: > > > From: Christopher R. Maden <crism@xxxxxxxxx> > Subject: Re: [xsl] using name() to generate a tag > dynamically in xsl output - FOLLOW UP > To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx > Date: Friday, February 26, 2010, 11:50 AM > > > mark bordelon wrote: > > Experimenting with it lead me to a follow-up > question. > > Altova is complaining about any axis or axis-like > syntax in my match > > statement. I have also tried > word/parent::**[@s_len<0] and various > > others. My idea is to get any node the parent of > <word> with that > > condition of its attribute. > > I was recently surprised to be reminded that match pattern > steps are > restricted in their syntax.B Assuming that the > double-asterisk was just > a typo in your e-mail, try *[word and @s_len < 0] > instead. > > ~Chris > -- > Chris Maden, text nerdB <URL: http://crism.maden.org/ > > bThe honest man, though eber sae poor, Is king ob men > for ab that.b > b Robert Burns, bIs There for Honest Povertyb > GnuPG Fingerprint: C6E4 E2A9 C9F8 71AC 9724 CAA3 19F8 6677 > 0077 C319
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] using name() to generate , mark bordelon | Thread | Re: [xsl] using name() to generate , Imsieke, Gerrit, le- |
Re: [xsl] using name() to generate , mark bordelon | Date | Re: [xsl] using name() to generate , Imsieke, Gerrit, le- |
Month |