English 中文(简体)
限制XML扫描仪中一个清单类型的长度
原标题:Constraining the length of a list type in an XML schema
  • 时间:2011-11-06 17:12:31
  •  标签:
  • xml
  • xsd

我为一套抽象的一组内容制定了XML图:

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified"
    xmlns:tns="http://www.dummy.com/xml/sets/"
    targetNamespace="http://www.dummy.com/xml/sets/">
    <xs:group name="SetElement">
        <xs:sequence>
            <xs:element name="Label" type="xs:string"/>
        </xs:sequence>
    </xs:group>
</xs:schema>

进口该表, 我正试图为一套固定物体设计XML图形,该物体的心脏元素储存了该装置的心脏。

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified"
    targetNamespace="http://www.dummy.com/xml/sets/"
    xmlns="http://www.dummy.com/xml/sets/">
    <xs:import namespace="http://www.dummy.com/xml/sets/"
        schemaLocation="setelement.xsd"/>
    <xs:element name="Cardinality" type="xs:nonNegativeInteger"/>
    <xs:simpleType name="SetElements">
        <xs:list itemType="SetElement"><xs:length value=""></xs:length></xs:list>
    </xs:simpleType>    
</xs:schema>

由于这套标准必须确切包含<编码>标准要素中规定的内容数目,因此,是否在使用该编号限制<代码>SetElements 清单类型的长度方面有任何余地?

是否有人建议解决这一一般性问题? 如果有任何模样收集或列出或确定标语,而知道其基本性,则是否有任何办法使用该图象来具体列出其基本要素清单?

感谢任何建议。 SRM。

问题回答

在XSD1.1中,你可以这样做,并说话。 与此类似:

<xs:assert test="Cardinality = count(data(SetElements))"/>

XSD 1.1 is supported in recent releases of Saxon and Xerces.

如果能使用XSD1.1,考虑增加Schematron验证阶段。

Michael Kay Saxonica





相关问题
how to represent it in dtd?

I have two element action and guid. guid is a required field when action is add. but when action is del it will not appear in file. How to represent this in dtd ?

.Net application configuration add xml-data

I need to add xml-content to my application configuration file. Is there a way to add it directly to the appSettings section or do I need to implement a configSection? Is it possible to add the xml ...

XStream serializing collections

I have a class structure that I would like to serialize with Xstream. The root class contains a collection of other objects (of varying types). I would like to only serialize part of the objects that ...

MS Word splits words in its XML format

I have a Word 2003 document saved as a XML in WordProcessingML format. It contains few placeholders which will be dynamically replaced by an appropriate content. But, the problem is that Word ...

Merging an XML file with a list of changes

I have two XML files that are generated by another application I have no control over. The first is a settings file, and the second is a list of changes that should be applied to the first. Main ...

How do I check if a node has no siblings?

I have a org.w3c.dom.Node object. I would like to see if it has any other siblings. Here s what I have tried: Node sibling = node.getNextSibling(); if(sibling == null) return true; else ...

Ordering a hash to xml: Rails

I m building an xml document from a hash. The xml attributes need to be in order. How can this be accomplished? hash.to_xml

热门标签