469,308 Members | 2,737 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,308 developers. It's quick & easy.

xsl: write only certain attribute

hello,
i've an xml file and i want to transform it to another one with only certain attribute in certain nodes (!)
for example, all the node have id, title and description are attributes.
but i want the first node display only title, the second id and title, the third only description, etc.

the xml is:
Expand|Select|Wrap|Line Numbers
  1. <guide id="" title="" description="">
  2.    <version id="" title="" description="">
  3.    <module id="" title="" description="">
  4.       <unit id="" title="" description="">
i write the following xsl file, but it work only for child on the root node (not for the child of the child...):
Expand|Select|Wrap|Line Numbers
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  3.  
  4.   <xsl:template match="@* | node()">
  5.     <xsl:copy>
  6.       <xsl:apply-templates select="@* | node()"/>
  7.     </xsl:copy>
  8.   </xsl:template>
  9.  
  10.   <xsl:template match="version">
  11.     <xsl:copy>
  12.       <xsl:copy-of select="@*[name() = 'id']"/>
  13.       <xsl:apply-templates select="version"/>
  14.     </xsl:copy>
  15.   </xsl:template>
  16.  
  17.   <xsl:template match="module">
  18.     <xsl:copy>
  19.       <xsl:copy-of select="@*[name() = 'id']"/>
  20.       <xsl:apply-templates select="module"/>
  21.     </xsl:copy>
  22.   </xsl:template>
  23.  
  24.   <xsl:template match="unit">
  25.     <xsl:copy>
  26.       <xsl:copy-of select="@*[name() = 'title']"/>
  27.     </xsl:copy>
  28.   </xsl:template>
  29.  
  30. </xsl:stylesheet>
  31.  
my idea is to have an output similar of the follow:
Expand|Select|Wrap|Line Numbers
  1. <guide title="">
  2.    <version id="">
  3.    <module id="" title="">
  4.       <unit title="" description="">
can anyone helps me, please?
(excuse me for my bad english)
Apr 15 '07 #1
1 1363
dorinbogdan
839 Expert 512MB
How are you testing it?
Please provide a valid XML that can be tested against.
Currently, I get a blank page if open the XML in IE browser.

If you use other tool (Saxon?) I cannot be of much help since I have no 3th party tool.

Thanks.
Apr 16 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

1 post views Thread by Philip | last post: by
3 posts views Thread by howardr101 | last post: by
4 posts views Thread by Hemal Pandya | last post: by
3 posts views Thread by Valvalis | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by harlem98 | last post: by
1 post views Thread by Geralt96 | last post: by
reply views Thread by harlem98 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.