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

Re: Problem with nested Stuff

Subject: Re: Problem with nested Stuff
From: JBryant@xxxxxxxxx
Date: Mon, 14 Nov 2005 14:19:11 -0600
div table nested
If all you want is to replace the contents of any element that has a myid
attribute with the value of the myid attribute, you can do it with two
templates: an identity transform and another template that matches any
element with a myid attribute. Here's a stylesheet that does it:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

  <xsl:output method="xml" version="1.0" omit-xml-declaration="no"
indent="yes"/>

  <xsl:template match="@*|node()">
    <xsl:copy><xsl:apply-templates select="@*|node()"/></xsl:copy>
  </xsl:template>

  <xsl:template match="*[@myid]">
    <xsl:copy>{<xsl:value-of select="@myid"/>}</xsl:copy>
  </xsl:template>

</xsl:stylesheet>

I tested it with Xalan Java 2.4.1 (after I added a root element to your
XML snippet).

The difference between my approach and Jon Gorman's approach is that I use
templates and he uses xsl:choose, but the approaches are otherwise very
similar. (Jon's response came in as I was writing my response, by the
way.)

I suspect you may want something more than what Jon and I have shown,
though, as it seems odd to me that you would want to throw away the
content of elements that have myid attributes.

Jay Bryant
Bryant Communication Services
(presently consulting at Synergistic Solution Technologies)



"Miladen Jolie" <my.office@xxxxxx>
11/14/2005 01:20 PM
Please respond to
xsl-list@xxxxxxxxxxxxxxxxxxxxxx


To
xsl-list@xxxxxxxxxxxxxxxxxxxxxx
cc

Subject
 Problem with nested Stuff






Hi,

i want to get from:

<div myid="test">blah</div>
<table>
  <tr>
    <td>test</td>
    <td myid="test2">blah2</td>
  </tr>
</table>

this:

<div>{test}</div>
<table>
  <tr>
    <td>test</td>
    <td>{test2}</td>
  </tr>
</table>

How can achieve this?

Thx in advance.

Miller

--
Highspeed-Freiheit. Bei GMX superg|nstig, z.B. GMX DSL_Cityflat,
DSL-Flatrate f|r nur 4,99 Euro/Monat*  http://www.gmx.net/de/go/dsl

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.