【发布时间】:2014-11-25 12:55:38
【问题描述】:
我有源xml文件
<?xml version="1.0" encoding="UTF-8"?>
<ns0:entry xmlns:ns0="http://www.w3.org/2005/Atom">
<ns0:content type="application/xml">
<ns0:properties>
<ns0:x>qwerty</ns0:x>
<ns0:y>OREQ</ns0:y>
<ns0:y>abc</ns0:y>
</ns0:properties>
</ns0:content>
我在 Lingamurthy 回复后更新的 xslt 文件如下所示
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:ns0="http://www.w3.org/2005/Atom" version="1.0">
<xsl:output method="xml" indent="yes"/>
<xsl:strip-space elements="*"/>
<xsl:param name="documentXML"/>
<xsl:variable name="temp" select="document($documentXML)"/>
<xsl:template match="ns0:entry">
<xsl:copy>
<xsl:copy-of select="$temp/ns0:entry/*" />
<xsl:copy-of select="*"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
documentXML上面的参数传递为
<?xml version="1.0" encoding="UTF-8"?>
<ns0:entry xmlns:ns0="http://www.w3.org/2005/Atom">
<ns0:link href="GetArtefactDetailsSet(ArtefactId)/EScHeaderSet" rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/EScHeaderSet" title="application/atom+xml;type=feed" type="EScHeaderSet">
<ns0:inline>
<ns0:feed/>
</ns0:inline>
</ns0:link>
</ns0:entry>
请注意,所有这些过程都在 tibco 中运行,并且 documentXML 参数的 isXMLDocument 标志为 true()
运行时出现以下错误 [javax.xml.transform.TransformerException] 在 XSLT 转换期间发生:javax.xml.transform.TransformerException:com.tibco.xml.xquery.ExprException:java.net.MalformedURLException:无协议:
我已经被困在这几天需要拼命完成这项工作。 生成的xml应该是这样的
<?xml version="1.0" encoding="UTF-8"?>
<ns0:entry xmlns:ns0="http://www.w3.org/2005/Atom">
<ns0:link href="GetArtefactDetailsSet(ArtefactId)/EScHeaderSet" rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/EScHeaderSet" title="application/atom+xml;type=feed" type="EScHeaderSet">
<ns0:inline>
<ns0:feed/>
</ns0:inline>
</ns0:link>
<ns0:content type="application/xml">
<ns0:properties>
<ns0:x>qwerty</ns0:x>
<ns0:y>OREQ</ns0:y>
<ns0:z>abc</ns0:z>
</ns0:properties>
</ns0:content>
</ns0:entry>
【问题讨论】:
-
我对 tibco 不熟悉,但是如果您传入的参数已经被视为 XML 文档,那么我不会在其上调用
document函数,我会简单地使用它,例如$documentXML/entry。但是请注意,整个样式表在处理您的输入数据时看起来很奇怪,因为 Xml 使用 Atom 命名空间,但 XSLT 没有考虑到这一点。此外,所使用的逗号运算符仅适用于 XSLT 2.0 处理器。 -
感谢您的回复,该文档可以使用 isXMLDocument 标志作为 xml 文档或 xml 字符串作为参数传递,我已经尝试使用和不使用
document(),根据下面 Lingamurthy 的回复我已经更新了 xml 我将对其进行编辑并更新我将删除 , 符号
标签: xml xslt xquery tibco xalan