Generic XSLT for any XML to Convert into many HTML Pages based on Nodes [closed]
Thanks in Advance, i have an XML file , which has got many Child nodes and in turn attribs as well..
Task is to generate web pages
I am able to generate web pages by
- Matching templates
- Attributes (@att)
- node elemants
i wish i could make it much generic .. so that it can loop through all nodes , find for attributes.
Print the Node name (as the Label Nam开发者_如何学Goe):Node Value or Attribute Value(in the text box)
Hope i am clear.
You can get the node and attribute name simply by using the name()
function. Here's a fairly minimal stylesheet that just lists the names of all node and attributes in a document. As is, it's not that useful, but should demonstrate the principle:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<ul>
<xsl:apply-templates />
</ul>
</xsl:template>
<xsl:template match="node()[name()]">
<li class="node">
<xsl:value-of select="name()" />
</li>
<xsl:apply-templates select="@* | node()"/>
</xsl:template>
<xsl:template match="@*">
<li class="attr">
<xsl:value-of select="name()" />
</li>
</xsl:template>
</xsl:stylesheet>
精彩评论