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

Re: getting Not well formed xslt output

Subject: Re: getting Not well formed xslt output
From: Wendell Piez <wapiez@xxxxxxxxxxxxxxxx>
Date: Tue, 10 Jul 2001 12:02:19 +0100
xslt not well formed
Yogesh:

This is a job for the step-wise identity stylesheet. (It appears in the XSLT spec, section 7.5.)

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

Basically this traverses the tree one node at a time, copying each node to output.

Add to this two templates, one that handles your 'DEST' attribute, and one that handles your 'imtask' attribute (since these are the only things in your input that are going to change).

<xsl:template match="@DEST">
  <xsl:copy>
    <xsl:value-of select="../@imtask"/>
  </xsl:copy>
</xsl:template>

<xsl:template match="@imtask"/>

The first copies the DEST attribute, except it takes the value of the same element's 'imtask' attribute for its value. The second removes the 'imtask' attribute. Both of these templates have a higher priority than the generic identity template, so will apply where they can.

The technique, or pattern, is very useful for such simple "scrub transforms" as yours. I'm sure it's described in the FAQ. Since it's based on the identity transform, your problem of knowing how many attributes there are, and which, simply goes away.

Good luck,
Wendell

BTW -- how'd this thread get its Subject line? It's basically useless: this has nothing to do with well-formedness.

At 04:23 PM 7/10/01, you wrote:
Hi Mike,
I have one problem like this:
my node is like this:
<ACTION TYPE="accept" LABEL="Next" task="go" DEST="#password" >

For SAXparsing in JAVA I make it well-formed like this:
<ACTION TYPE="accept" LABEL="Next" task="go" DEST="#password"
imtask="20"></ACTION>

On This code if I apply XSLT I want output like this:
<ACTION TYPE="accept" LABEL="Next" task="go" DEST="20" >(20 is value of
imtask)

Now I am having a problem how will I construct this node with keeping all
previous attributes as it is and changing value of dest attribute and not
closing it.If I write a template for this how I will be adding exact no. of
attributes and not closing it.

Please advice.
Thanx in advance,
-Yogesh


XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list


======================================================================
Wendell Piez                            mailto:wapiez@xxxxxxxxxxxxxxxx
Mulberry Technologies, Inc.                http://www.mulberrytech.com
17 West Jefferson Street                    Direct Phone: 301/315-9635
Suite 207                                          Phone: 301/315-9631
Rockville, MD  20850                                 Fax: 301/315-8285
----------------------------------------------------------------------
  Mulberry Technologies: A Consultancy Specializing in SGML and XML
======================================================================


XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list



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.