【发布时间】:2019-11-13 03:06:21
【问题描述】:
我有一个模式感知 XSLT 转换效果很好。但是,XSLT 的预期用户可能无法访问架构感知处理器。因此,我想编写一些代码,将我的架构感知XSLT 转换为基本级别的处理器可以使用的 XSLT。
出于我的目的,模式感知结构的使用仅限于匹配模板,即
<xsl:template match="element(*, Candidate)">...</>
我不希望这是一个全自动过程。我想要的是生成一个XSLT,对于XSD 中的每个complexType,都会在指定的浮出水面XSDelement 中找到它的用途。
示例代码:
<xsd:schema xmlns="example.xsd" xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="example.xsd" elementFormDefault="qualified" version="0.0">
<xsd:element name="Candidate" type="Candidate"/>
<xsd:complexType name="Candidate">
<xsd:sequence>
<xsd:element name="Code" type="Code" minOccurs="0" maxOccurs="unbounded"/>
<xsd:element name="Name" type="xsd:string" minOccurs="0"/>
<xsd:element name="PartyId" type="Code" minOccurs="0"/>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="Code">
<xsd:sequence>
<xsd:element name="Value" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
</xsd:schema>
元素Candidate 的预期输出是这样的:
<complexType_usages>
<usage complexType="Code" path="Candidate/Code" />
<usage complexType="Code" path="Candidate/Party" />
</complexType_usages>
【问题讨论】: