开发者

Generic XSLT for any XML to Convert into many HTML Pages based on Nodes [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 11 years ago.

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

  1. Matching templates
  2. Attributes (@att)
  3. 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>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜