嘗試使用XSL樣式錶轉換簡單的XML文檔。我現在正在使用XMLspy,但是最終目標是瀏覽器。「預期的QName」 - 嘗試從屬性值創建元素
的XML:
<doc>
<str name="organizationName">Me</str>
<str name="rights">BY-NC</str>
<str name="date">2011-05-23</str>
<str name="type">Collection</str>
<bool name="collectionPubliclyVisible">true</bool>
<str name="publisher">Pub</str>
<str name="creator">Me</str>
<long name="id">2656</long>
<int name="rank">2</int>
<str name="contributor">ME</str>
<str name="description">This Collection archives 900+ feeds from the network of US based NOAA observation stations recording current climatic conditions, in addition to a daily constructed XML Zip file generated by NOAA.</str>
<str name2="name">NOAA - XML Feeds of Observed Current Conditions</str>
<date name="updated_dt">2011-06-03T21:04:56Z</date>
<str name="relation"/>
<str name="format">zip</str>
<date name="created_dt">2011-05-31T22:36:07Z</date>
<date name="timestamp">2011-06-17T21:54:24.116Z</date>
</doc>
的XSL:
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" indent="yes"/>
<xsl:template match="/">
<xsl:element name="metadata">
<xsl:apply-templates select="doc"/>
</xsl:element>
</xsl:template>
<xsl:template match="doc">
<xsl:apply-templates select="child::node()"/>
</xsl:template>
<xsl:template match="child::node()">
<element name="{@name}" xmlns="http://www.w3.org/1999/XSL/Transform">
<xsl:value-of select="."/>
</element>
</xsl:template>
</xsl:stylesheet>
非常感謝,我已經在這幾個小時也沒有用。
-Graham
這是很酷的男人!和...? –