我有这个XML:
<?xml version="1.0" encoding="utf-8" ?>
<IMPORT mode="FULL">
....
</IMPORT>
Run Code Online (Sandbox Code Playgroud)
我正在尝试使用以下XSLT样式表转换它:
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<xsl:element name="import">
<xsl:attribute name="mode">
<xsl:value-of select="@mode"/>
</xsl:attribute>
....
</xsl:element>
</xsl:template>
Run Code Online (Sandbox Code Playgroud)
我的问题是以下行似乎不起作用:
<xsl:value-of select="@mode"/>
Run Code Online (Sandbox Code Playgroud)
我得到的只是
<import mode="">
Run Code Online (Sandbox Code Playgroud)
而不是预期的:
<import mode="FULL">
Run Code Online (Sandbox Code Playgroud)
有线索吗?
你实际上并不是这个IMPORT元素.
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<xsl:apply-templates select="IMPORT"/>
</xsl:template>
<xsl:template match="IMPORT">
<xsl:element name="import">
<xsl:attribute name="mode">
<xsl:value-of select="@mode"/>
</xsl:attribute>
....
</xsl:element>
</xsl:template>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
7118 次 |
| 最近记录: |