Element basics
Questions about XML that are not covered by the other forums should go here.
-
- Posts: 5
- Joined: Wed May 04, 2011 4:03 pm
Element basics
Hi! I am trying to figure out if an element can have both a type and attributes. So that something like this can be validated via a schema:
Thanks!
Code: Select all
<element name="Hello">World</element>
<element name="This">Text</element>
Thanks!
-
- Posts: 2879
- Joined: Tue May 17, 2005 4:01 pm
Re: Element basics
Hello,
Of course it can have both. The following schema snippet covers this:
Obviously you can use a different type than xs:string.
You can easily generate a schema for content like this in Oxygen:
- Make the XML snippet well-formed(put it inside an XML root) and open it in Oxygen:
- Use the schema generator/converter(Document -> Schema -> Generate/Convert Schema), select W3C XML Schema check the output filename of the generated schema and press Convert.
You will obtain a simple XML Schema that contains an element declaration similar to the one mentioned above.
Regards,
Adrian
Of course it can have both. The following schema snippet covers this:
Code: Select all
<xs:element name="element">
<xs:complexType>
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute name="name" type="xs:string"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:element>
You can easily generate a schema for content like this in Oxygen:
- Make the XML snippet well-formed(put it inside an XML root) and open it in Oxygen:
Code: Select all
<root>
<element name="Hello">World</element>
<element name="This">Text</element>
</root>
You will obtain a simple XML Schema that contains an element declaration similar to the one mentioned above.
Regards,
Adrian
Adrian Buza
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
Return to “General XML Questions”
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