Specify different Use attribute of SimpleType when inherited?
This should cover W3C XML Schema, Relax NG and DTD related problems.
-
- Posts: 2
- Joined: Mon Nov 14, 2011 9:16 pm
Specify different Use attribute of SimpleType when inherited?
First, I am evaluating OxygenXML and so far have found it to be a very good, capable xml and xml schema development tool. Thank you!
That said, I am also relatively new to xml schemas, their syntax and capabilities for describing a particular xml syntax. So, given this example schema code:
I am wondering how to achieve what I asked for in the annotation for Element2 in the code?
Thanks in advance for any help with this!
That said, I am also relatively new to xml schemas, their syntax and capabilities for describing a particular xml syntax. So, given this example schema code:
Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
<xs:complexType name="BaseElementType">
<xs:attribute name="Attr1" type="xs:string" use="required"/>
<xs:attribute name="Attr2" type="xs:unsignedByte" use="optional"/>
<xs:attribute name="Attr3" type="xs:unsignedShort" use="optional"/>
</xs:complexType>
<xs:element name="Element1" type="BaseElementType">
<xs:annotation>
<xs:documentation>
This element uses the base element attributes as specified, where Attr1
is a required attribute, but Attr2 and Attr3 are optional.
</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="Element2" type="BaseElementType">
<xs:annotation>
<xs:documentation>
This element uses the base element attributes but for this element I
want Attr2 to be a required attribute.
</xs:documentation>
</xs:annotation>
</xs:element>
</xs:schema>
Thanks in advance for any help with this!
-
- Site Admin
- Posts: 2095
- Joined: Thu Jan 09, 2003 2:58 pm
Re: Specify different Use attribute of SimpleType when inherited?
One possibility is to define a new type that restricts the base type making that attribute required and then use that for the second element:
Best Regards,
George
Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
<xs:complexType name="BaseElementType">
<xs:attribute name="Attr1" type="xs:string" use="required"/>
<xs:attribute name="Attr2" type="xs:unsignedByte" use="optional"/>
<xs:attribute name="Attr3" type="xs:unsignedShort" use="optional"/>
</xs:complexType>
<xs:element name="Element1" type="BaseElementType">
<xs:annotation>
<xs:documentation>
This element uses the base element attributes as specified, where Attr1
is a required attribute, but Attr2 and Attr3 are optional.
</xs:documentation>
</xs:annotation>
</xs:element>
<xs:complexType name="BaseElementType2">
<xs:complexContent>
<xs:restriction base="BaseElementType">
<xs:attribute name="Attr2" type="xs:unsignedByte" use="required"/>
</xs:restriction>
</xs:complexContent>
</xs:complexType>
<xs:element name="Element2" type="BaseElementType2">
<xs:annotation>
<xs:documentation>
This element uses the base element attributes but for this element I
want Attr2 to be a required attribute.
</xs:documentation>
</xs:annotation>
</xs:element>
</xs:schema>
George
George Cristian Bina
-
- Posts: 2
- Joined: Mon Nov 14, 2011 9:16 pm
Re: Specify different Use attribute of SimpleType when inherited?
George, thanks for the very quick response. What you suggested works well. Thank you!
I may ask additional questions in other areas as I hit road blocks, so I hope your tolerance for a beginning schema developer is set high!
I may ask additional questions in other areas as I hit road blocks, so I hope your tolerance for a beginning schema developer is set high!

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