0

如何在不列出“xsl:for-each select="name|lastname|third"”的情况下自动选择下一个块?

XSL:

<fo:table>
       <fo:table-body>
          <xsl:for-each select="table">
         <fo:table-row>
           <xsl:for-each select="name|lastname|third">
            <fo:table-cell>
               <fo:block><xsl:value-of select="."/></fo:block>
            </fo:table-cell>
           </xsl:for-each>
         </fo:table-row>
           </xsl:for-each>
       </fo:table-body>
</fo:table>

XML:

    <table>
        <name>Name</name>
        <lastname>Lastname</lastname>
        <third>Third</third>
    </table>
4

1 回答 1

0
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"   xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="msxsl">
<xsl:output method="xml" indent="yes"/>


<xsl:template match="/">

<table>
  <table-body>
    <xsl:for-each select="table/child::*">
      <table-row>

          <table-cell>
            <block>
              <xsl:value-of select="current()"/>
            </block>
          </table-cell>

      </table-row>
    </xsl:for-each>
  </table-body>
</table>

</xsl:template>
</xsl:stylesheet>

输出:

<?xml version="1.0" encoding="utf-8"?>
<table>
<table-body>
<table-row>
  <table-cell>
    <block>Name</block>
  </table-cell>
</table-row>
<table-row>
  <table-cell>
    <block>Lastname</block>
  </table-cell>
</table-row>
<table-row>
  <table-cell>
    <block>Third</block>
  </table-cell>
</table-row>
</table-body>
</table>
于 2013-03-19T08:08:26.723 回答