xsd->xslt

最近忙活了一阵子,搞的就是通过xsd生成xsl,网上倒是找到了类似的工具,貌似都是商用付费的,看不到源码也拿不到正式版,我们项目里要整个这个东西(不过不需要很强大),我对图形化处理那块不是很熟,就整后台了,基本思路就是:
1、通过目标XSD生成目标XML,这个一步很多工具都做得到,不过为了后面的做准备,我在这个xml里添加了一些额外的属性,比如maxOccurs,maxOccurs之类。
2、把这个xml的元素和属性都转化为xslt标签,再加上xsl:if,xsl:for-each之类,当然不能忘了给这些xslt元素的选择器加上xpath值,这个值就靠前台提供咯。
目前基本上实现了xsd的大部分属性约束的解析并生成相应的xsl,接下来是进一步优化并支持更多属性的解析。
(2)根据下列XML Schema文档定义的XML文档的结构及每个元素的数据类型,自行书写XML文档的数据内容,并设计该XML文档在页面中显示的样式,写出对映的XML文档及对映的xsl文件。 编写折半法查找的程序。 <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <xsd:simpleType name="bookprice"> <xsd:restriction base="xsd:decimal"> <xsd:totalDigits value="6"/> <xsd:fractionDigits value="2"/> <xsd:minInclusive value="0.00"/> <xsd:maxInclusive value="100.00"/> <!-- 用fractionDigits,totalDigits时 数据 类型应写成 base="xsd:decimal" 写成 float 错误 --> </xsd:restriction> </xsd:simpleType> <xsd:simpleType name="category"> <xsd:restriction base="xsd:token"> <xsd:enumeration value="小说"/> <xsd:enumeration value="散文"/> <xsd:enumeration value="传记"/> <xsd:enumeration value="诗歌"/> <xsd:enumeration value="武侠"/> <xsd:enumeration value="纪实"/> </xsd:restriction> </xsd:simpleType> <xsd:simpleType name="categoylist"> <xsd:list itemType="category"/> </xsd:simpleType> <xsd:simpleType name="threeBookCate"> <xsd:restriction base="categoylist"> <xsd:length value="3"/> </xsd:restriction> </xsd:simpleType> <xsd:element name="booklist"> <xsd:complexType> <xsd:sequence> <xsd:element name="categoylist" type="categoylist"/> <xsd:element name="threeBookCategory" type="threeBookCate"/> <xsd:element ref="book"/> </xsd:sequence> </xsd:complexType> </xsd:element> <xsd:element name="book"> <xsd:complexType> <xsd:sequence> <xsd:element name="title" type="xsd:string"/> <xsd:element name="author" type="xsd:string"/> <xsd:element name="price" type="bookprice"/> <xsd:element name="resume" type="xsd:string"/> <xsd:element name="recommendation" type="xsd:string"/> <xsd:element name="publish" minOccurs="0" maxOccurs="unbounded"> <xsd:complexType> <xsd:sequence> <xsd:element name="publisher" type="xsd:string"/> <xsd:element name="pubdate" type="xsd:date"/> </xsd:sequence> </xsd:complexType> </xsd:element> <xsd:element name="category" type="category"/> </xsd:sequence> <xsd:attribute name="isbn" type="xsd:string"/> </xsd:complexType> </xsd:element> </xsd:schema>
最新发布
05-24
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值