【发布时间】:2018-08-08 21:07:41
【问题描述】:
我需要获取 c:batch 节点的每个子节点。 与节点不匹配。我做错了什么?任何帮助表示赞赏。提前致谢。
<?xml version="1.0" encoding="UTF-8"?>
<c:batch xmlns:a="http://www.test.com/data/6/archive"
xmlns:i="http://www.test.com/data/6/archive/import"
xmlns="http://www.test.com/dos/asap"
xmlns:n1="http://www.test.com/dos"
xmlns:c="http://www.test.com/data/6/capture">
<s-20 file="00000001.pdf" checked="true">
<code>X12345</code>
<type>data</type>
</s-20>
<s-20 file="00000002.pdf" checked="false">
<code>X67890</code>
<type>data</type>
</s-20>
<s-20 file="00000003.pdf" checked="true">
<code>X87687</code>
<type>data</type>
</s-20>
</c:batch>
样式表:
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:a="http://www.test.com/data/6/archive"
xmlns:i="http://www.test.com/data/6/archive/import"
xmlns="http://www.test.com/dos/asap"
xmlns:n1="http://www.test.com/dos"
xmlns:c="http://www.test.com/data/6/capture">
<xsl:output method="xml" indent="yes"/>
<xsl:template match="/">
<xsl:element name="Documents">
<xsl:value-of select="count(s-20)"/>
<xsl:apply-templates />
</xsl:element>
</xsl:template>
<xsl:template match="s-20">
<xsl:value-of select="code"/>
</xsl:template>
</xsl:stylesheet>
【问题讨论】:
标签: xml xslt namespaces