XSLT:从xsd获取枚举 [英] XSLT: Get enumeration from xsd
本文介绍了XSLT:从xsd获取枚举的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
< xs:simpleType name =SO>
< xs:restriction base =xs:string>
< xs:枚举值=Mac OS X/>
< xs:枚举值=Windows Server/>
< xs:枚举值=Windows Vista/>
< xs:枚举值=Windows XP/>
< xs:枚举值=Windows 7/>
< xs:枚举值=Windows 8/>
< xs:枚举值=Windows 8.1/>
< xs:枚举值=Ubuntu/>
< / xs:restriction>
< / xs:simpleType>
,我需要在XSL中得到它,以便在javascript组合框中使用它。有什么办法吗?
解决方案
此样式表将输出一个< option />
s:
< xsl:stylesheet version =1.0xmlns:xsl =http://www.w3。 org / 1999 / XSL / Transformxmlns:xs =http://www.w3.org/2001/XMLSchema>
< xsl:template match =xs:simpleType [@ name ='SO'] / xs:restriction>
< xsl:for-each select =xs:enumeration>< option>< xsl:value-of select =@ value/>< / option>< / xsl:的for-each>
< / xsl:template>
< / xsl:stylesheet>
I've this enum in the xsd file:
<xs:simpleType name="SO">
<xs:restriction base="xs:string">
<xs:enumeration value="Mac OS X"/>
<xs:enumeration value="Windows Server"/>
<xs:enumeration value="Windows Vista"/>
<xs:enumeration value="Windows XP"/>
<xs:enumeration value="Windows 7"/>
<xs:enumeration value="Windows 8"/>
<xs:enumeration value="Windows 8.1"/>
<xs:enumeration value="Ubuntu"/>
</xs:restriction>
</xs:simpleType>
and I need to get it in the XSL to use it in a javascript combobox. There's any way to do it?
解决方案
This stylesheet will output a list of <option/>
s:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xsl:template match="xs:simpleType[@name='SO']/xs:restriction">
<xsl:for-each select="xs:enumeration"><option><xsl:value-of select="@value"/></option></xsl:for-each>
</xsl:template>
</xsl:stylesheet>
这篇关于XSLT:从xsd获取枚举的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文