xml editor

Products

Features

  EPUB
Supported platforms

Supports Windows 7 & Mac OS X Lion

Ready for XML Editor data server software
W3C Member

Element basics

Questions about XML that are not covered by the other forums should go here.

Element basics

Postby senseiwa » Tue Jul 12, 2011 5:43 pm

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:

Code: Select all
<element name="Hello">World</element>
<element name="This">Text</element>



Thanks!
senseiwa
 
Posts: 5
Joined: Wed May 04, 2011 4:03 pm

Re: Element basics

Postby adrian » Wed Jul 13, 2011 5:10 pm

Hello,

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>

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:
Code: Select all
<root>
    <element name="Hello">World</element>
    <element name="This">Text</element>
</root>

- 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
Adrian Buza
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
adrian
 
Posts: 979
Joined: Tue May 17, 2005 4:01 pm


Return to General XML Questions

Who is online

Users browsing this forum: No registered users and 0 guests

cron
XML Editor | XML Author | WYSIWYG Editors | Schema Editor | XSD Documentation | XSL/XSLT Editor | XQuery | XML Databases | SVN Client
© 2002-2011 SyncRO Soft Ltd. All rights reserved. | Sitemap | Privacy Policy | This website was created & generated with <oXygen/>® XML Editor