[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: using name() to generate a tag dynamically in xsl

Subject: Re: using name() to generate a tag dynamically in xsl output - STILL TRYING
From: "Imsieke, Gerrit, le-tex" <gerrit.imsieke@xxxxxxxxx>
Date: Fri, 26 Feb 2010 22:36:59 +0100
Re:  using name() to generate a tag dynamically in xsl
But isn't what David suggested exactly what you need?

<xsl:template match="*[word][@s_len&lt;2.5]">

Gerrit


On 26.02.2010 22:24, mark bordelon wrote:
I was not clear. And I should have posted some xml, so here it is:

<text>
    <line id="1" s_len="2.8">
       <word id="1">Thou</word>
       <word id="2">still</word>
       <word id="3">unravish'd</word>
       <word id="4">bride</word>
       <word id="5">of</word>
       <word id="6">quietness</word>,
    </line>
    <clause id="2" s_len="2.4">
       <word id="7">The</word>
       <word id="8">quick</word>-
       <word id="9">brown</word>
       <word id="10">fox</word>
       <word id="11">jumped</word>
       <word id="12">over</word>
       <word id="13">lazy</word>
       <word id="14">dog</word>,
     </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&lt;2.5] | line[@s_len&lt;2.5]">
<xsl:element name="{name()}">
	<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&lt;2.5]"
match="word/../*[@s_len&lt;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: 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&lt;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. Assuming that the double-asterisk was just a typo in your e-mail, try *[word and @s_len< 0] instead.

~Chris

-- Gerrit Imsieke GeschC$ftsfC<hrer / Managing Director le-tex publishing services GmbH Weissenfelser Str. 84, 04229 Leipzig, Germany Phone +49 341 355356 110, Fax +49 341 355356 510 gerrit.imsieke@xxxxxxxxx, http://www.le-tex.de

Registergericht / Commercial Register: Amtsgericht Leipzig
Registernummer / Registration Number: HRB 24930

GeschC$ftsfC<hrer: Gerrit Imsieke, Svea Jelonek,
Thomas Schmidt, Dr. Reinhard VC6ckler

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.