将多个属性添加到架构中的多个元素(add multiple attributes to multiple elements in schema)

编程入门 行业动态 更新时间:2024-10-05 19:11:32
多个属性添加到架构中的多个元素(add multiple attributes to multiple elements in schema)

我无法弄清楚如何将多个节点的属性添加到xsd文件中。 这是我的XML文件。

<?xml version="1.0" encoding="utf-8"?> <xs:Root xmlns:xs="http://tempuri.org/SchemaFile" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://tempuri.org/SchemaFile SchemaFile.xsd" xmlns:elementFormDefault="qualified"> <xs:Node name="attributeName"> <xs:data name="attributeName" amount="total" /> // These are unbounded. </xs:Node> </xs:Root>

这是我到目前为止所拥有的。 我不能得到任何工作。

<sch:element name="Root"> <sch:complexType> <sch:sequence> <sch:element name="Node" maxOccurs="unbounded"> <sch:complexType> <sch:simpleContent> <sch:extension base="sch:string"> <sch:attribute name="name" type="sch:string"/> </sch:extension> </sch:simpleContent> </sch:complexType> </sch:element> </sch:sequence> </sch:complexType> </sch:element>

我还尝试了一个全局添加属性类型,但我不能让它工作。 当我使用它所说的类型时,我不能拥有任何其他复杂或简单类型以及xmlnode节点的属性声明。

I can't figure out how to add attributes for multiple nodes into an xsd file. This is my XML File.

<?xml version="1.0" encoding="utf-8"?> <xs:Root xmlns:xs="http://tempuri.org/SchemaFile" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://tempuri.org/SchemaFile SchemaFile.xsd" xmlns:elementFormDefault="qualified"> <xs:Node name="attributeName"> <xs:data name="attributeName" amount="total" /> // These are unbounded. </xs:Node> </xs:Root>

Here is what I have so far. I can't get anything to work though.

<sch:element name="Root"> <sch:complexType> <sch:sequence> <sch:element name="Node" maxOccurs="unbounded"> <sch:complexType> <sch:simpleContent> <sch:extension base="sch:string"> <sch:attribute name="name" type="sch:string"/> </sch:extension> </sch:simpleContent> </sch:complexType> </sch:element> </sch:sequence> </sch:complexType> </sch:element>

I also tried a global to add the attribute type but i can't get it to work. When i use the type it says i can't have any other complex or simple types along with the attribute declaration for the xmlnode Node.

最满意答案

我发现这似乎有效。 这是我之前搞砸的顺序。根

<sch:element name="Root"> <sch:complexType> <sch:sequence> <sch:element name="Node" maxOccurs="unbounded"> <sch:complexType> <sch:sequence> <sch:element name="Data" maxOccurs="unbounded"> <sch:complexType> <sch:attribute name="name"/> <sch:attribute name="amount"/> </sch:complexType> </sch:element> </sch:sequence> <sch:attribute name="name"/> </sch:complexType> </sch:element> </sch:sequence> </sch:complexType> </sch:element>

I have found that this seems to work. It was the ordering that I messed up on earlier.Root

<sch:element name="Root"> <sch:complexType> <sch:sequence> <sch:element name="Node" maxOccurs="unbounded"> <sch:complexType> <sch:sequence> <sch:element name="Data" maxOccurs="unbounded"> <sch:complexType> <sch:attribute name="name"/> <sch:attribute name="amount"/> </sch:complexType> </sch:element> </sch:sequence> <sch:attribute name="name"/> </sch:complexType> </sch:element> </sch:sequence> </sch:complexType> </sch:element>

更多推荐

本文发布于:2023-07-09 10:11:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1085553.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:多个   架构   属性   元素   add

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!