Re: [xsl] getting Not well formed xslt output

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

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

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

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:value-of select="../@imtask"/>

<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,

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"

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

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,

XSL-List info and archive:

Wendell Piez                            mailto:wapiez@xxxxxxxxxxxxxxxx
Mulberry Technologies, Inc.      
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:

Current Thread