我在使用添加名称空间代码时遇到错误。
我在while循环中添加了名称空间代码。对于第一次迭代它正常工作。对于第二次迭代,它给出了以下错误。
错误:
exception class="oracle.xml.parser.v2.XMLDOMException">
invalid character : in name
<stack>
<f>oracle.xml.util.XMLUtil.validateQualifiedName#525</f>
<f>oracle.xml.parser.v2.XMLDocument.createElementNS#2705</f>
<f>oracle.xml.parser.v2.XMLDocument.otherImportNode#2350</f>
<f>oracle.xml.parser.v2.XMLDocument.importNode#2326</f>
<f>oracle.xml.parser.v2.XMLDocument.otherImportNode#2459</f>
<f>oracle.xml.parser.v2.XMLDocument.importNode#2326</f>
<f>com.collaxa.cube.xml.dom.DOMUtil.copyElement#558</f>
<f>com.collaxa.cube.xml.dom.DOMUtil.copyObjHelper#300</f>
我使用下面在while循环中添加Namesapces代码.while循环处理第一次迭代的多个记录。它能够处理。但是对于第二次迭代,它给出了错误。
添加命名空间代码:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:vbs="http://www.w3.org/1999/XSL/Transform" xmlns:msxml="urn:schemas-microsoft-com:xslt">
<xsl:output omit-xml-declaration="yes" />
<xsl:template match="node()|@*">
<xsl:copy>
<xsl:apply-templates select="node()|@*" />
</xsl:copy>
</xsl:template>
<!-- Just change the match="/*" to match="*" ; if you want to add namespace in all elements -->
<xsl:template match="*">
<xsl:element name="inp1:{local-name()}" namespace="http://xmlns.oracle.com/pcbpel/adapter/db/sp/Call856OutboundProcedure1">
<xsl:apply-templates select="node()|@*" />
</xsl:element>
</xsl:template>
</xsl:stylesheet>
答案 0 :(得分:0)
你在这里提供了相当稀疏的信息,但我建议尝试这种方法(在样式表根目录而不是<xsl:element>
中指定名称空间uri:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:vbs="http://www.w3.org/1999/XSL/Transform"
xmlns:msxml="urn:schemas-microsoft-com:xslt"
xmlns:inp1="http://xmlns.oracle.com/pcbpel/adapter/db/sp/Call856OutboundProcedure1">
<xsl:output omit-xml-declaration="yes" />
<xsl:template match="node()|@*">
<xsl:copy>
<xsl:apply-templates select="node()|@*" />
</xsl:copy>
</xsl:template>
<!-- Just change the match="/*" to match="*" ; if you want to add namespace in all elements -->
<xsl:template match="*">
<xsl:element name="inp1:{local-name()}">
<xsl:apply-templates select="node()|@*" />
</xsl:element>
</xsl:template>
</xsl:stylesheet>