2013-03-30 25 views
0

您好在使用添加名称空间代码时遇到错误。在添加XSLT中的名称空间时发生错误

我已经在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> 

我使用的同时loop.The里面加入以下代码Namesapces而第一iteration.It循环过程中多条记录能够process.but第二次迭代是给出错误。

添加命名空间代码:

<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

你的源XML是什么样子的?你说你正在使用while循环,看起来像什么? – JLRishe

+0

如果这是你正在使用的真正转换,那么对于主要的XSLT处理器(其中11个)我有,也许是这样Oracle XSLT处理器中的一个错误。 –

回答

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>