将变量传递给 XSD 文件,将其转换为 XML 文件
我有一个 XML 方案,其中有 4 个不同的维度。然而,后来创建的 XML 标签并不相同,必须使用用户输入或其他内容来创建。 xml 标签名称应该是 xml 方案中的变量。我想知道是否可以将这些变量传递给 xml 方案,以便稍后可以使用单独的 xml 标签自动创建单独的 xml 文件。 我是一名初级程序员,在 y 方面有一点经验,
很抱歉我的英语不好,或者如果很难理解英语不是我的母语。我希望我写的内容是可以理解的。
<?xml version = "1.0" encoding = "UTF-8"?>
<xs:schema xmlns:xs = "http://www.w3.org/2001/XMLSchema">
<xs:element name = "xml-tag1" maxOccurs = "unbounded" minOccurs = "0">
<xs:complexType>
<xs:sequence>
<xs:element name = "xml-tag2" maxOccurs = "unbounded" minOccurs = "0">
<xs:complexType>
<xs:sequence>
<xs:element name = "xml-tag3" maxOccurs = "unbounded" minOccurs = "0">
<xs:complexType>
<xs:sequence>
<xs:element name = "xml-tag4" maxOccurs = "unbounded" minOccurs = "0">
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
xml-tag1 = input
xml-tag2 = input
xml-tag3 = input
xml-tag4 = input
I have a XML scheme in which i have 4 different dimensions. The later created XML Tags however arent the same and have to be created with userinput or something. The xml tag names should be variables in the xml scheme. I am wondering if it is possible, that i can pass these variables to the xml scheme so i can later automatically create individual xml files with individual xml tags.
Im a beginner programmer with a little bit of experience in y
Sorry for my bad english or if it is hard to understand english is not my mothertongue. I hope, that what i wrote is understandable.
<?xml version = "1.0" encoding = "UTF-8"?>
<xs:schema xmlns:xs = "http://www.w3.org/2001/XMLSchema">
<xs:element name = "xml-tag1" maxOccurs = "unbounded" minOccurs = "0">
<xs:complexType>
<xs:sequence>
<xs:element name = "xml-tag2" maxOccurs = "unbounded" minOccurs = "0">
<xs:complexType>
<xs:sequence>
<xs:element name = "xml-tag3" maxOccurs = "unbounded" minOccurs = "0">
<xs:complexType>
<xs:sequence>
<xs:element name = "xml-tag4" maxOccurs = "unbounded" minOccurs = "0">
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
xml-tag1 = input
xml-tag2 = input
xml-tag3 = input
xml-tag4 = input
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
XSD 不直接支持这一点。您可以通过使用元素名称的实体引用来参数化模式,也可以使用 XSLT 动态生成模式。
然而,如果我为你提供专业建议,我会问一些关于你是否走在正确道路上的尖锐问题。您正在尝试的事情非常奇怪,我希望看到不使用更传统的解决方案的强有力的理由。
XSD doesn't support this directly. You could parameterise the schema by using entity references for the element names, or you could generate the schema dynamically using XSLT.
However, if I were advising you professionally, I would be asking some searching questions about whether you are going down the right road. What you're attempting is pretty weird, and I would want to see a strong rationale for not using a more conventional solution.