473,378 Members | 1,405 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

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

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

Similar topics

1
by: John | last post by:
I have an input document that contains a large base64 encoded document. This document also declares a schema location in the root element. I want to write an XSL stylesheet that makes an exact...
1
by: Philip | last post by:
Hi, I am trying to output certain nodes inside another. I have an xml template with field definitions for a form, and this includes textfields, labels, checkboxes etc plus fieldssets. I defined...
2
by: D. Alvarado | last post by:
Hello, I am outputting HTML from an XSLT and I am having trouble setting the value of a form-action field based on certain conditions. Here is the non-working code: <xsl:template...
8
by: Sebastian Kerekes | last post by:
Greetings, I'm developing an application that supports multiple languages. In my XSL I use variables to place the text where it belongs to. At the top of the document I include those variables -...
0
by: kmunderwood | last post by:
I am having trouble excluding select xml out to HTML using xsl I want to ignore some xml and turn others red I can not find the right way to both: 1. Only show the <tag> that want to, and...
3
by: howardr101 | last post by:
Hi, I'm really new to this XSL stuff and there's a lot of information out there on the web, I just can't seem to find a definitive answer to my question, hence...... In FO, I know that you...
4
by: Hemal Pandya | last post by:
Hello, I am hoping this is a simple question with a straightforward solution. I do not understand xsl much, so I apologize in advance if I am asking a stupid question. Is it possible to write...
3
by: Valvalis | last post by:
Hello, I am trying to set a class attribute of a text.item element to the value of its nearest ancestor. I want to do this in the case that the class of the text.item is currently a blank string....
1
by: sarah12 | last post by:
HI, This time , I need to write the XSL to transform the following document : <?xml version="1.0"?> <nplbiblio rundate="20080110"> <document status="U" creadate="19990410">...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.