Xml Saxon过早地求值xsl:attribute set
这与使用最新的Saxon EE 9.8对XSLT转换的输入进行模式感知验证有关 我的XSLT文件包含以下内容 名称空间和相关架构的定义如下:Xml Saxon过早地求值xsl:attribute set,xml,xslt,xsd,saxon,xslt-3.0,Xml,Xslt,Xsd,Saxon,Xslt 3.0,这与使用最新的Saxon EE 9.8对XSLT转换的输入进行模式感知验证有关 我的XSLT文件包含以下内容 名称空间和相关架构的定义如下: <xsl:import-schema namespace="http://www.fpml.org/2005/FpML-4-2" schema-location="/path/to/some_swbml.xsd"/> 这是一个玩具的例子,上面的样板是不合理的 当我将其与以下设备一起使用时,效果良好: java net.sf.saxon.Tr
<xsl:import-schema namespace="http://www.fpml.org/2005/FpML-4-2" schema-location="/path/to/some_swbml.xsd"/>
这是一个玩具的例子,上面的样板是不合理的
当我将其与以下设备一起使用时,效果良好:
java net.sf.saxon.Transform -sa -ext:on -it -o:output.xml -xsl:example.xslt
这是意料之中的,因为据我所知,“-sa”只检查输出的XML文档
这不起作用:
java net.sf.saxon.Transform -val:lax -ext:on -it -o:output.xml -xsl:example.xslt
给予:
FORG0001: Attribute @xsl:use-attribute-sets is not allowed on element <SWBML>
元素上不允许使用FORG0001:Attribute@xsl:use属性集
我的问题是-验证程序在尝试验证
之前是否应该处理属性集?在我看来,它似乎在抱怨输出XML文档中不允许使用XSLT指令,这当然是正确的,但它似乎过早地进行了检查
生成的XML有效:
<SWBML xmlns="http://www.fpml.org/2005/FpML-4-2" version="4_2">
如使用“-sa”选项转换所示
我不确定这是XSLT的限制,还是Saxon处理中的错误?我觉得我应该可以这样对我
有什么想法吗?我无法复制这个 我运行了这个样式表:
<xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
exclude-result-prefixes="#all"
version="3.0">
<xsl:import-schema namespace="http://www.fpml.org/2005/FpML-4-2">
<xs:schema targetNamespace="http://www.fpml.org/2005/FpML-4-2">
<xs:element name="SWBML">
<xs:complexType>
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute name="version" type="xs:decimal"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:element>
</xs:schema>
</xsl:import-schema>
<xsl:template name="xsl:initial-template">
<xsl:result-document method="xml" validation="strict">
<SWBML xmlns="http://www.fpml.org/2005/FpML-4-2" xsl:use-attribute-sets="ir">
GENERATE SOME MORE XML TO BE VALIDATED BY THE XSD
</SWBML>
</xsl:result-document>
</xsl:template>
<xsl:attribute-set name="ir">
<xsl:attribute name="version">4.2</xsl:attribute>
</xsl:attribute-set>
</xsl:transform>
它运行良好
在我看来,似乎出于某种原因,您正在验证样式表本身。可能样式表使用构造
文档(“”
)来读取自己的源代码,在这种情况下,松散的验证将导致此失败。如果这不是解释,请提供您正在做的事情的更多细节。感谢vm提供的线索-XSLT中的其他地方是SWBML名称空间的自查找
。为了澄清,有没有办法删除文档(“”)
?在我看来,通过设计,答案是“否”,但我想知道是否有一种方式可以对给定文档说“不验证”?您可以使用saxon:doc()函数,该函数有第二个参数,可用于设置验证(和其他)选项。但不管怎么说,文档(“”)是一种好的实践吗?XSLT 3.0确实不需要它,这意味着只有在源代码可用时才能执行样式表,这限制了部署选项。要更改,我将文档替换为
,然后将SWBML命名空间设置为禁用。我将
替换为
。。。。这会在swbBrokerTradeId的第行处中断-静态错误,然后XTTE1510:复杂类型Q的内容模型中不允许使用元素swbHeader{http://www.fpml.org/2005/FpML-4-2}SWBML
。swbHeader是SWBML的孩子,swbBrokerTradeId是swbHeader的孩子。对不起,我想这是一个补充问题。将补充问题打包成评论不是一种好的做法;评论过于局限,无法清晰地呈现信息。提出一个新问题。
<SWBML xmlns="http://www.fpml.org/2005/FpML-4-2" version="4_2">
<xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
exclude-result-prefixes="#all"
version="3.0">
<xsl:import-schema namespace="http://www.fpml.org/2005/FpML-4-2">
<xs:schema targetNamespace="http://www.fpml.org/2005/FpML-4-2">
<xs:element name="SWBML">
<xs:complexType>
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute name="version" type="xs:decimal"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:element>
</xs:schema>
</xsl:import-schema>
<xsl:template name="xsl:initial-template">
<xsl:result-document method="xml" validation="strict">
<SWBML xmlns="http://www.fpml.org/2005/FpML-4-2" xsl:use-attribute-sets="ir">
GENERATE SOME MORE XML TO BE VALIDATED BY THE XSD
</SWBML>
</xsl:result-document>
</xsl:template>
<xsl:attribute-set name="ir">
<xsl:attribute name="version">4.2</xsl:attribute>
</xsl:attribute-set>
</xsl:transform>
-xsl:test.xsl -sa -val:lax -it -t