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

Re: is this valid <xsl:template match="@id"> ?

Subject: Re: is this valid <xsl:template match="@id"> ?
From: SLakshman@xxxxxxxxx
Date: Thu, 2 Jan 2003 13:42:29 -0600
xsl template match id
thanks Joerg. it worked...

Can you tell why is this restriction ?  When we create CHILD ELEMENT or
ATTRIBUTE using DOM, the order did not seem to matter...

regards

Saravanan L


Tuesday, December 31, 2002 6:07 AM
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
cc:
From: Joerg Heinicke <joerg.heinicke@xxxxxx>
Subject: Re:  is this valid <xsl:template match="@id"> ?



Hello Saravanan,

you can not create an attribute after an element, so change

 > <xsl:template match="Item">
 >   <xsl:element name="Item">
 >     <xsl:apply-templates select="Name"></xsl:apply-templates>
 >     <xsl:apply-templates select="@ID"></xsl:apply-templates>
 >   </xsl:element>
 > </xsl:template>

to

 > <xsl:template match="Item">
 >   <xsl:element name="Item">
 >     <xsl:apply-templates select="@ID"></xsl:apply-templates>
 >     <xsl:apply-templates select="Name"></xsl:apply-templates>
 >   </xsl:element>
 > </xsl:template>

Regards,

Joerg


SLakshman@xxxxxxxxx wrote:
> Here are the samples of XML, XSLT and resulting XML I got...
>
> *************** source XML *************************************
> <?xml version="1.0"?>
> <Items>
>       <Item ID="1234">
>             <Name>ABCDE</Name>
>       </Item>
>       <Item ID="2345">
>             <Name>BCDE</Name>
>       </Item>
>       <Item ID="3456">
>             <Name>CDE</Name>
>       </Item>
>       <Item ID="4567">
>             <Name>DE</Name>
>       </Item>
>       <Item ID="5678">
>             <Name>E</Name>
>       </Item>
>       <Item ID="6789">
>             <Name></Name>
>       </Item>
> </Items>
> **************************************************************
> *************** XSLT *************************************
> <?xml version="1.0"?>
> <xsl:stylesheet version="1.0" xmlns:xsl
> ="http://www.w3.org/1999/XSL/Transform">
>       <xsl:output method="xml" version="1.0" indent="yes"></xsl:output>
>       <xsl:strip-space elements="*"></xsl:strip-space>
>       <xsl:template match="/">
>             <xsl:apply-templates select="Items"></xsl:apply-templates>
>       </xsl:template>
>       <xsl:template match="Items">
>             <xsl:element name="Items">
>                   <xsl:apply-templates select
="Item"></xsl:apply-templates>
>             </xsl:element>
>       </xsl:template>
>       <xsl:template match="Item">
>             <xsl:element name="Item">
>                   <xsl:apply-templates select
="Name"></xsl:apply-templates>
>                   <xsl:apply-templates select="
@ID"></xsl:apply-templates>
>             </xsl:element>
>       </xsl:template>
>       <xsl:template match="Name">
>             <xsl:element name="Name">
>                   <xsl:apply-templates></xsl:apply-templates>
>             </xsl:element>
>       </xsl:template>
>       <xsl:template match="@ID">
>             <xsl:attribute name="ID">
>                   <xsl:value-of select="."></xsl:value-of>
>             </xsl:attribute>
>       </xsl:template>
> </xsl:stylesheet>
>
> *******************************************************************
>
> *************** result XML *************************************
>
> <?xml version="1.0"?>
> <Items>
>       <Item>
>             <Name>ABCDE</Name>
>       </Item>
>       <Item>
>             <Name>BCDE</Name>
>       </Item>
>       <Item>
>             <Name>CDE</Name>
>       </Item>
>       <Item>
>             <Name>DE</Name>
>       </Item>
>       <Item>
>             <Name>E</Name>
>       </Item>
>       <Item>
>             <Name></Name>
>       </Item>
> </Items>
> *******************************************************************
>
> thanks
>
> Saravanan
> Monday, December 30, 2002 6:15 PM
> To: "'xsl-list@xxxxxxxxxxxxxxxxxxxxxx'" <xsl-list@xxxxxxxxxxxxxxxxxxxxxx>
> cc:
> From: "Martinez, Brian" <brian.martinez@xxxxxxxx>
> Subject: RE:  is this valid <xsl:template match="@id"> ?
>
>
>
>
>>From: SLakshman@xxxxxxxxx [mailto:SLakshman@xxxxxxxxx]
>>Sent: Monday, December 30, 2002 4:44 PM
>>Subject:  is this valid <xsl:template match="@id"> ?
>>
>>I would like to create a template that matches attribute id
>>in all elements
>>
>><xsl:template match="@id">
>>
>>this is not working with MSXML... is it correct to use such syntax ?
>
>
> The syntax is legal, and MSXML (at least v.4.0) should have no trouble
with
> it.  Your problem likely lies elsewhere (perhaps the select expression in
> your apply-templates elements, or the XPath syntax in the template
itself).
> You should post some sample input/output and the relevant XSLT if you
want
> more specific help.
>
> cheers,
> b.



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




 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.