2013-03-30 50 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> 
相關問題