• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Knute Snortum
  • Bear Bibeault
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Frits Walraven
  • Carey Brown
  • Tim Holloway

XSL Problem

 
Ranch Hand
Posts: 104
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Folks!

I have an xml doc which I want to render as HTML.



with the following xsl..



Here the html output only has the id value and nothing else.


How do I use a template to match the sub-root element and display its id and use a different template to match its child nodes.


Anyone who can help me out here???



Cheers
 
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hello,

I'm also a new to xsl-xml but i think u should use...

<xsl:for-each select="//root/sub-root">
<xsl:value-of select="name"/>
</xsl:for-each>

coz for me it worked fine
 
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl utput method="html"/>

<xsl:template match="/">
<html>
<xsl:apply-templates/>
</html>
</xsl:template>

<xsl:template match="sub-root">
<i><xsl:value-of select="@id" /></i>

<xsl:apply-templates/>
</xsl:template>

<xsl:template match="sub-root/node1"> <!-- This never executes. -->
<b><xsl:value-of select="." /></b>
</xsl:template>

<xsl:template match="sub-root/node2"> <!-- Neither does this -->
<h2><xsl:value-of select="." /></h2>
</xsl:template>
</xsl:stylesheet>

but this is not the good solution. You need to tell us your exact requirement.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!