enumeration
This should cover W3C XML Schema, Relax NG and DTD related problems.
-
- Posts: 4141
- Joined: Fri Mar 28, 2003 2:12 pm
Re: enumeration
Post by sorin_ristache »
Hello,
An attribute value can be an enumeration of values that are extracted from other element. Can you give more details about the problem, maybe an example of an attribute and the location of the enumeration of values that you need to put in the attribute?
Regards,
Sorin
An attribute value can be an enumeration of values that are extracted from other element. Can you give more details about the problem, maybe an example of an attribute and the location of the enumeration of values that you need to put in the attribute?
Regards,
Sorin
-
- Posts: 3
- Joined: Sun Mar 20, 2011 8:06 pm
Re: enumeration
Sorin, thanks for your interest,
here's an example where I would want the enumeration for the attribute "Atype_Name" to contain a list of what the user has input for "NameA":
here's an example where I would want the enumeration for the attribute "Atype_Name" to contain a list of what the user has input for "NameA":
Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="Base">
<xs:complexType>
<xs:sequence>
<xs:element maxOccurs="unbounded" name="A">
<xs:complexType>
<xs:attribute name="NameA" type="xs:string"/>
</xs:complexType>
</xs:element>
<xs:element maxOccurs="unbounded" name="B">
<xs:complexType>
<xs:sequence>
<xs:element maxOccurs="unbounded" name="Atype">
<xs:complexType>
<xs:attribute name="Atype_Name">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="ChooseAnames"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="NameB"/>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
-
- Posts: 4141
- Joined: Fri Mar 28, 2003 2:12 pm
Re: enumeration
Post by sorin_ristache »
Do you want to restrict the values that the user is allowed to enter as value for the NameA attribute and keep a list of the values entered by the user in the Atype_Name attribute? In this case you should have a schema like the following. Otherwise please give an example of XML document that is valid and another one that is invalid.
Regards,
Sorin
Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="Base">
<xs:complexType>
<xs:sequence>
<xs:element maxOccurs="unbounded" name="A">
<xs:complexType>
<xs:attribute name="NameA" type="EnumerationOfNames"/>
</xs:complexType>
</xs:element>
<xs:element maxOccurs="unbounded" name="B">
<xs:complexType>
<xs:sequence>
<xs:element maxOccurs="unbounded" name="Atype">
<xs:complexType>
<xs:attribute name="Atype_Name">
<xs:simpleType>
<xs:list itemType="EnumerationOfNames"/>
</xs:simpleType>
</xs:attribute>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="NameB"/>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:simpleType name="EnumerationOfNames">
<xs:restriction base="xs:string">
<xs:enumeration value="allowed_value_1"/>
<xs:enumeration value="allowed_value_2"/>
<xs:enumeration value="allowed_value_3"/>
</xs:restriction>
</xs:simpleType>
</xs:schema>
Regards,
Sorin
-
- Posts: 4141
- Joined: Fri Mar 28, 2003 2:12 pm
Re: enumeration
Post by sorin_ristache »
Please give one or two examples of valid and invalid XML documents for the restriction that you want to encode in the XML Schema.plebel wrote:I did want to restrict the contents of "Atype_Name" to any of the values that actually got used for the NameA.
If you to set some values in a restriction in an XML Schema you have to know/decide these values in advance, before creating any XML instance documents for that schema. If you want to allow in "Atype_Name" any value that is used in "NameA" what is it that you want to restrict? I think some examples of XML documents will clarify that. Let's start from a few examples of XML instance documents and based on them we can create an XML Schema that can validate such XML documents.
Regards,
Sorin
Jump to
- Oxygen XML Editor/Author/Developer
- ↳ Feature Request
- ↳ Common Problems
- ↳ DITA (Editing and Publishing DITA Content)
- ↳ SDK-API, Frameworks - Document Types
- ↳ DocBook
- ↳ TEI
- ↳ XHTML
- ↳ Other Issues
- Oxygen XML Web Author
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Content Fusion
- ↳ Feature Request
- ↳ Common Problems
- Oxygen JSON Editor
- ↳ Feature Request
- ↳ Common Problems
- Oxygen PDF Chemistry
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Feedback
- ↳ Feature Request
- ↳ Common Problems
- Oxygen XML WebHelp
- ↳ Feature Request
- ↳ Common Problems
- XML
- ↳ General XML Questions
- ↳ XSLT and FOP
- ↳ XML Schemas
- ↳ XQuery
- NVDL
- ↳ General NVDL Issues
- ↳ oNVDL Related Issues
- XML Services Market
- ↳ Offer a Service