473,405 Members | 2,171 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,405 software developers and data experts.

xslt: to html

mickey0
142 100+
Hello,
I have an xslt like:
Expand|Select|Wrap|Line Numbers
  1. <root>
  2.     <name> Mike   </name>                    
  3.      <dog> Bark </dog>
  4.     <name> Jenny </name>
  5.     <dog> buck </dog>
  6. </root>
  7.  
Expand|Select|Wrap|Line Numbers
  1. //file.xslt:
  2. ...............................
  3.  <xsl:template match="/"> 
  4.      <html>
  5.              <xsl:apply-templates select="//name" />
  6.              <xsl:apply-templates select="//dog" />             
  7.      </html>
  8.  </xsl:template>
  9.  
  10.   <xsl:template match="//dog">
  11.     <xsl:value-of select="text()" />
  12.   </xsl:template>
  13.   <xsl:template match="//name">
  14.     <xsl:value-of select="text()" />
  15.   </xsl:template>
  16.  
The problem is that this will show:
Mike
Jenny
Bark
Buck
whereas I need
Mike
Bark
Jenny
Buck
How can I do that, please?

thanks in advance...
Jul 6 '08 #1
4 1623
jkmyoung
2,057 Expert 2GB
Expand|Select|Wrap|Line Numbers
  1. <xsl:apply-templates select="//name | //dog" />
  2. or 
  3. <xsl:apply-templates/>
  4.  
  5. or if name's and dog's are paired together:
  6. <xsl:template match="name">
  7.     <xsl:value-of select="text()" />
  8.     <xsl:value-of select="following-sibling:dog[1]" />
  9. </xsl:template>
  10.  
Jul 7 '08 #2
mickey0
142 100+
Hi thanks I prefer the second for simplicity...but:
and what I I had to the same but I had to put a tag (eg. <character>) at begin?
Expand|Select|Wrap|Line Numbers
  1.       <root>
  2.           <name> Mike   </name>                   
  3.            <dog> Bark </dog>
  4.           <name> Jenny </name>
  5.            <character> Mr Donald Duck </character>
  6.           <dog> buck </dog>
  7.            <person> Mr Mickey </person>
  8.       </root>
  9.  
I need this:
Expand|Select|Wrap|Line Numbers
  1. The characters of Walt Disney are:
  2. Mr Donald Duck
  3. Mr Mickey
  4. Mike
  5. Bark
  6. Jenny
  7. buck
  8.  
Thanks in advance...
Jul 7 '08 #3
mickey0
142 100+
Hi thanks I prefer the second for simplicity...but:
and what I I had to the same but I had to put a tag (eg. <character>) at begin?
Expand|Select|Wrap|Line Numbers
  1.       <root>
  2.           <name> Mike   </name>                   
  3.            <dog> Bark </dog>
  4.           <name> Jenny </name>
  5.            <character> Mr Donald Duck </character>
  6.           <dog> buck </dog>
  7.            <person> Mr Mickey </person>
  8.       </root>
  9.  
I need this:
Expand|Select|Wrap|Line Numbers
  1. The characters of Walt Disney are:
  2. Mr Donald Duck
  3. Mr Mickey
  4. Mike
  5. Bark
  6. Jenny
  7. buck
  8.  
Thanks in advance...
Does anyone have a hint, please?

Cheers,
Jul 9 '08 #4
jkmyoung
2,057 Expert 2GB
?
Expand|Select|Wrap|Line Numbers
  1. <xsl:template match="name">
  2.     <xsl:value-of select="text()" />
  3.     <xsl:value-of select="following-sibling:*[1]" />
  4. </xsl:template>
  5.  
Jul 10 '08 #5

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

Similar topics

2
by: Tom Corcoran | last post by:
I am working to ease updating of a html page by transforming 2 xml files. I was going to use xslt for this and had bought 2 unopened books, wrox xslt and o'reilly's xslt cookbook. But am now...
4
by: Ringo Langly | last post by:
Hi all, I'm a seasoned web programmer, but I've never touched XSLT. It's always been one of those acronyms I've never needed to educate myself on. Now... we're working with a web content...
12
by: gipsy boy | last post by:
Hello, I have sort of a big problem. I would really appreciate any help you could give me. I made a web service in C++ that throws XML to the client (browser). But, the XSLT transormation...
5
by: Fred | last post by:
Not much expertise on XSLT and trying to understand it's uses when creating apps in VS.NET? If I wanted flexibility on the UI (View aspect of M.V.C.): - How does it compare with creating...
4
by: Stephen | last post by:
I have the following that outputs an xml file to a div using ajax: <script type="text/javascript"> function ajaxXML(url,control_id){ if (document.getElementById) { var x =...
5
by: shauldar | last post by:
Is there a way (tool, hack...) to create an XSL:FO from an XSLT + XML files? My motivation is that we want to use a tool to design reports, and from that "design" generate both HTML (via XSLT)...
4
by: Moogy | last post by:
I'm pulling my hair out here. First, I'm new to XML, so that doesn't help, but none of this makes any sense to me. All I'm trying to do is take a simple source XML file and translate it with an...
0
by: Christopher M. Lauer | last post by:
I have done my best to answer this question but can not find the proper set of commands. I would like to transform an xml file (in code behind) and display its output in a specific html tag,...
3
by: Teksure | last post by:
Hi group, searching in the Internet I found two products for XML which incorporate a very robust debugger for XSL/XSLT, I would like you to see these products and then, give me your opinion about...
2
jkmyoung
by: jkmyoung | last post by:
Here's a short list of useful xslt general tricks that aren't taught at w3schools. Attribute Value Template Official W3C explanation and example This is when you want to put dynamic values...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.