3
<Products>
<Product ProductID="1">
<productName>Ball</productName>
<Color>Green</Color>
</Product>
<Product ProductID="2">
<productName>Doll</productName>
<Color>White</Color>
</Product>
</Products>
我有一個XML輸入像above.But i的創建具有產品名作爲屬性和產品ID作爲下product.below的元件的產品元件具有的問題是,我的代碼。XML轉化
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:fn="http://www.w3.org/2005/xpath-functions">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:template match="//Products">
<html>
<body>
<Products>
<xsl:for-each select="//Product">
<xsl:call-template name="Import"/>
</xsl:for-each>
</Products>
</body>
</html>
</xsl:template>
<xsl:template name="Import" match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()" />
</xsl:copy>
</xsl:template>
</xsl:stylesheet>