自动生成满足XSD格式要求的XML文件

Eleve 2009-01-20 11:20:02
有个活,没有给我数据源,只是让我自动生成满足一个挺复杂的XSD文件的XML文件,写个工具自动生成一个XML文件,满足这个XSD格式的文件要求没有数据源怎么产正啊?给了个XML文件做例子,让我弄,谁能帮我出出主意?
...全文
672 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
Eleve 2009-02-01
  • 打赏
  • 举报
回复
由于内容过长,我只好省略了很多复杂类型的元素
Eleve 2009-02-01
  • 打赏
  • 举报
回复

<?xml version="1.0" encoding="UTF-8" ?>
<schema targetNamespace="http://schemas.microsoft.com/msus/2002/12/ReleaseProposal" xmlns="http://www.w3.org/2001/XMLSchema" xmlns:rel="http://schemas.microsoft.com/msus/2002/12/ReleaseProposal" xmlns:pub="http://schemas.microsoft.com/msus/2002/12/Publishing" xmlns:upd="http://schemas.microsoft.com/msus/2002/12/Update" xmlns:bt="http://schemas.microsoft.com/msus/2002/12/BaseTypes" xmlns:drv="http://schemas.microsoft.com/msus/2002/12/Handlers/WindowsDriver" elementFormDefault="qualified" attributeFormDefault="unqualified">
<annotation>
<documentation>
Release specific xml schema
</documentation>
</annotation>
<!--

Imported schemas

-->
<import namespace="http://schemas.microsoft.com/msus/2002/12/BaseTypes" schemaLocation="BaseTypes.xsd" />
<import namespace="http://schemas.microsoft.com/msus/2002/12/Update" schemaLocation="Update.xsd" />
<import namespace="http://schemas.microsoft.com/msus/2002/12/Publishing" schemaLocation="Publishing.xsd" />

<element name="ReleaseProposal" type="rel:ReleaseProposal"/>

<complexType name="ReleaseProposal">
<annotation>
<documentation>
Represents release proposal for a particular case. All the elements are optional as in different scenarios many of them are not required.
For example I can simple save to disk by putting in release date and time.
</documentation>
</annotation>
<sequence>
<element name="Case" type="rel:Case" minOccurs="1" maxOccurs="1"/>
<!-- Release Plan -->
<element name="ReleasePlan" type="rel:ReleasePlan" minOccurs="0" maxOccurs="1"/>
<!-- Update Properties -->
<element name="Properties" type="rel:Properties" minOccurs="0" maxOccurs="1"/>
<!-- Installation impact -->
<element name="InstallationImpact" type="rel:InstallationImpact" minOccurs="0" maxOccurs="1"/>
<!-- Exception bug number -->
<element name="ExceptionBugNumbers" type="rel:BugNumbersString" minOccurs="0" maxOccurs="1" />
<!-- Update proposal -->
<element name="UpdateProposalList" type="rel:UpdateProposalList" minOccurs="0" maxOccurs="1" />
<!-- Planned changes - This is not finalized. PM to follow up on how API users will use this.-->
<element name="PlannedChanges" type="rel:PlannedChanges" minOccurs="0" maxOccurs="1"/>
</sequence>
<attribute name="ReleaseId" type="bt:Guid" use="required"/>
<attribute name="ReleaseDateTime" type="dateTime" use="required" />
</complexType>

<complexType name="InstallationImpact">
<annotation>
<documentation>
Installation impact due to this update
</documentation>
</annotation>
<attribute name="RebootBehavior" type="upd:InstallationRebootBehavior" use="optional" default="NeverReboots" />
<attribute name="RequireExclusiveInstallation" type="boolean" use="optional" default="false"/>
<attribute name="CanRequestUserInput" type="boolean" use="optional" default="false"/>
<attribute name="CanUninstallViaAddRemovePrograms" type="boolean" use="optional" default="true"/>
<attribute name="CanUninstallViaWSUS" type="boolean" use="optional" default="true"/>
</complexType>


<complexType name="Change">
<sequence>
<element name="UpdateId" type="bt:Guid" minOccurs="1" maxOccurs="unbounded"/>
</sequence>
<attribute name ="ChangeName" type="rel:ChangeName" use="required"/>
<attribute name="ChangeDescription" type="rel:STString1500" use="required"/>
</complexType>

<complexType name="PlannedChanges">
<annotation>
<documentation>
Planned changes for this update.
</documentation>
</annotation>
<sequence>
<element name="Change" type="rel:Change" minOccurs="1" maxOccurs="unbounded"/>
</sequence>
</complexType>

</schema>
Eleve 2009-02-01
  • 打赏
  • 举报
回复
蒋晟,新年好,很抱歉再次打搅你,我在使用XSD.exe生成类文件的时候出现了问题:
“Warning: cannot generate classes because no top-level elements with complex type were found.”
我要生成C#类的xsd文件包含了其他的一些XSD文件,好像不太好弄,希望大侠你能指点,谢谢了!
<XSD文件随后附上,谢谢咧:D>
蒋晟 2009-01-28
  • 打赏
  • 举报
回复
用xsd.exe生成一个类,编译生成的代码,再序列化到XML
smartcatiboy 2009-01-28
  • 打赏
  • 举报
回复
mark不懂
king19840811 2009-01-21
  • 打赏
  • 举报
回复
mark
蒋晟 2009-01-21
  • 打赏
  • 举报
回复
http://www.stylusstudio.com/xml_generator.html
Eleve 2009-01-21
  • 打赏
  • 举报
回复
我是否应该构建一个可以生成产生数据的类?如何构建呢?
Eleve 2009-01-21
  • 打赏
  • 举报
回复
谢谢蒋晟的回复,但是我无法使用这样的工具来生成XML的
跟相关的人沟通了一下,他的回复是:
"what u will have to do is create objects of this dummy values and call serialize method to convert objects to xml"
所以我肯定没办法使用工具输出XML文件了,有这样现成的类吗?麻烦再多点提示,谢谢

8,906

社区成员

发帖
与我相关
我的任务
社区描述
XML/XSL相关问题讨论专区
社区管理员
  • XML/XSL社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧