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

RE: Copy element content to another nested empty eleme

Subject: RE: Copy element content to another nested empty element
From: TeleServices <teleservices@xxxxxxxxx>
Date: Fri, 2 May 2008 05:47:53 -0700
RE:  Copy element content to another nested empty eleme
[Sorry if this starts another thread - this is my first reply.  I am
subscribing to the digest and I did not receive a direct reply to my
post.  So I am replying via the digest.  I am sure I am not doing this
correctly and I apologize - feel free to explain the proper procedure
- thanks!]

Anyway, thanks for the reply!  We are 90% there.  Except for a minor
typo ("<xslapply-templates" - missing colon), I thought you had done
it! As the HTML rendered perfectly.  However, on closer inspection I
realized the the entire option elements had be copied and not just
their content as I intended originally.  Here is a snippet:

===== Current Result =====
The first phrase element is <span class="phrase"><option id="value1">a
simple phrase</option></span>.  And the second phrase element is <span
class="phrase"><option id="value2">also a simple
phrase</option></span>, and the third phrase element <span
class="phrase"><option id="value3">could be a simple phrase</option>
</span> as well.
=====

===== Desired Result =====
The first phrase element is <span class="phrase">a simple
phrase</span>.  And the second phrase element is <span
class="phrase">also a simple phrase</span>, and the third phrase
element <span class="phrase">could be a simple phrase</span> as well.
=====

I tried tacking on a /text():

<xsl:apply-templates
select="//lists/list[@name=$list]/option[@id=$phrase]/text()"/>

But that broke it it again.  And I can see that I just flattened
things out again.

Then I tried a match="option" template but that was unsuccessful.

So the question is how can we follow the nested nodes, but copy only
the CONTENT of the nodes?

Thanks again for your help.  And again my apologies for not knowing
how to properly use this mailing list...

-Kiel

>
>  Date: Thu, 1 May 2008 15:56:10 +0100
>  To: <xsl-list@xxxxxxxxxxxxxxxxxxxxxx>
>  From: "Michael Kay" <mike@xxxxxxxxxxxx>
>  Subject: RE:  Copy element content to another nested empty element
>  Message-ID: <975ECD4F953A44948E3CF800D8AF4E9E@Sealion>
>
>  I think your basic problem is here:
>
>  <xsl:template match="phrase">
>   <xsl:variable name="phrase" select="@name"/>
>   <xsl:variable name="list" select="@list"/>
>   <span class="phrase"><xsl:value-of
>  select="//lists/list[@name=$list]/option[@id=$phrase]"/></span>
>  </xsl:template>
>
>  You are taking the "value-of" an option element (which flattens it to a
>  string), but the option element actually has internal structure that needs
>  to be further processed. So try this instead:
>
>  <xsl:template match="phrase">
>   <xsl:variable name="phrase" select="@name"/>
>   <xsl:variable name="list" select="@list"/>
>   <span class="phrase">
>      <xslapply-templates
>  select="//lists/list[@name=$list]/option[@id=$phrase]"/>
>   </span>
>  </xsl:template>
>
>  I haven't tested this, but it should be the only change you need to make.
>  Except that if your data contains cycles, your code will probably blow up
>  with a "stack full" error.
>
>  Michael Kay
>  http://www.saxonica.com/

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.