一个XSD一个XML我想创建一个XSLT,可以改变一个XML,使所有的元素和属性未在XSD定义被排除在输出XML(从XSLT) 。转化根据使用XSLT
可以说你有这个XSD。
<xs:element name="parent">
<xs:complexType>
<xs:sequence>
<xs:element name="keptElement1" />
<xs:element name="keptElement2" />
</xs:sequence>
<xs:attribute name="keptAttribute1" />
<xs:attribute name="keptAttribute2" />
</complexType>
</xsd:element>
你有这个输入XML
<parent keptAttribute1="kept"
keptAttribute2="kept"
notKeptAttribute3="not kept"
notKeptAttribute4="not kept">
<notKeptElement0>not kept</notKeptElement0>
<keptElement1>kept</keptElement1>
<keptElement2>kept</keptElement2>
<notKeptElement3>not kept</notKeptElement3>
</parent>
然后我想有输出XML这样看。
<parent keptAttribute1="kept"
keptAttribute2="kept">
<keptElement1>kept</keptElement1>
<keptElement2>kept</keptElement2>
</parent>
我可以通过指定元素来做到这一点,但这是关于我的xslt技能达到的。对于所有元素和所有属性,我通常都会遇到问题。