开发者

How to generate XML from XSD using perl

i am trying to genarate XML from xsd using perl can anyone guide me in right direction thank you

<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
        targetNamespace="urn:books"
        xmlns:bks="urn:books">
 <xsd:element name="books" type="bks:BooksForm"/>
<xsd:complexType name="BooksForm">
<xsd:sequence>
  <xsd:element name="book" 
              type="bks:BookForm" 
              minOccurs="0" 
              maxOccurs="unbounded"/>
</xsd:sequence>
 </xsd:complexType>
 <xsd:complexType name="BookForm">
<xsd:sequence>
  <xsd:element name="author"   type="xsd:string"/>
  <xsd:element name="title"    type="xsd:string"/>
  <xsd:element name="genre"    type="xsd:string"/>
  <xsd:element n开发者_如何转开发ame="price"    type="xsd:float" />
  <xsd:element name="pub_date" type="xsd:date" />
  <xsd:element name="review"   type="xsd:string"/>
</xsd:sequence>
<xsd:attribute name="id"   type="xsd:string"/>
  </xsd:complexType>
</xsd:schema>


I can't think of anything that specifically generates example XML from and XSD file in Perl. However if I were approaching the task I would start by looking at XML::Compile and XML::Pastor which both support some form of XSD -> Perl marshaling. There may be some way to boostrap their XSD parsing and build a random document generator from that.

Another, much less favorable, option is to use my own XML::Toolkit to generate objects from the XSD file and use those to build a generator for your document. This wouldn't be trivial or even necessarily "sane", but I think it should be possible.

There simply aren't many tools for XSD in Perl at the moment.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜