在创建XSD时需要帮助

编程入门 行业动态 更新时间:2024-10-26 07:34:15
本文介绍了在创建XSD时需要帮助的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我是xsd的新手.我正在尝试创建一个xsd,以便我的xml应该采用以下方式.

I'm new to xsd. I'm trying to create a xsd so that my xml should be in the following way..

<Info> <Val name="n_1">A</Val> <Val name="n_2">123</Val> <Val name="n_3">2012-05-05T00:00:00</Val> </Info>

我创建的xsd就是这样.

The xsd which I created is in this way..

<xs:element name="Info"> <xs:complexType> <xs:sequence> <xs:element name="n_1" type="xs:string"/> <xs:element name="n_2" type="xs:integer"/> <xs:element name="n_3" type="xs:dateTime"/> </xs:sequence> </xs:complexType> </xs:element>

这显然无助于满足我的要求..但是,此时此刻,我感到很震惊..如何创建3个属性值不同的元素"val" ...即使我做到了然后我将以某种方式获得列表错误列表.我该如何管理?

This obviously did not help in meeting my requirements.. But at this point of time I'm struck about one thing .. how to create 3 elements "val" whose attribute value is different... Even if I make it somehow then i will get list of lists error.. how can I manage that?

我实际上正在编写此xsd,以便可以将excel中的数据转换为xml. 要添加一些关于我的excel的信息,一行是一组,其中一列是Info(最糟糕的是:|,因为我有3个Val代表一个Info)...

I'm actually writing this xsd so that my data in excel can be converted to xml.. To add something about my excel, one row is a set in which one column is Info (worst thing comes here :| as I have 3 Val's for one Info) ...

我最初以为这个xml是错误的,但是我错了..这是标准的输出/输入xml ..

I initially thought this xml is wrong but I was wrong.. it is a standard output/input xml..

在实现这一目标方面的任何帮助都是可取的.

Any help in achieving this would be appreciable.

先谢谢了..:)

推荐答案

尝试使用此XSD.这将强制Val节点的" name "属性具有唯一性.

Try this XSD.This enforces uniqueness of "name" attribute of Val nodes.

<?xml version="1.0" encoding="utf-8"?> <xs:schema xmlns:xs="www.w3/2001/XMLSchema"> <xs:element name="Info" > <xs:complexType> <xs:sequence> <xs:element name="Val" maxOccurs="unbounded"> <xs:complexType> <xs:simpleContent > <xs:extension base="xs:anySimpleType"> <xs:attribute name="name" use="required" /> </xs:extension> </xs:simpleContent> </xs:complexType> </xs:element> </xs:sequence> </xs:complexType> <xs:unique name="uniqueNameForValList"> <xs:selector xpath="Val" /> <xs:field xpath="@name" /> </xs:unique> </xs:element>

更多推荐

在创建XSD时需要帮助

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

发布评论

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

>www.elefans.com

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