XSD: and Labels

F

fedro

Dear Group,

on an existing project, i found this:

<docDefinition id="1">
<tagDefinition id="2" label="Bild" tagName="..

....

Now that look very like XSD and i like to do so, but i haven't found an
attribute in definitions fpr the "label" attribute here.

Any suggestions?

Thanks in advance,
Dominik
 
G

George Bina

Hi Dominik,

That does not look like XSD.
You may wish to add mode details and eventual samples of what you are
looking for as I do not understand much from your post.

Best Regards,
George
 
F

fedro

i wanted to transform this XML-Structure to XSD.

OLD:
<docDefinition id="1">
<tagDefinition id="2" label="Bild" tagName="bild">
<attribute id="3" label="Ausrichtung" name="ausrichtung"
type="choice">
<value id="4" label="Links fließend">links</value>
<value id="5" label="Rechts fließend">rechts</value>
<value id="6" label="mittig">mitte</value>
</attribute>
</tagDefinition>
</docDefinition>


I started like this:
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:element name="bild" id="2" >
<xsd:complexType/>
</xsd:element>
</xsd:schema>

So i can "translate" the old tag ("tagDefinition") into xsd:element
with attribute "name". BUT this tag also got an attribute called
label="Bild".

Now i'm looking for the best way to tell the element, that it has got a
label. I tried with <xsd:annotation/>, but that look very dirty
and so i'm asking the group for best practices...
 
G

George Bina

Hi Dominik,

There are tools that provided with a set of XML documents (one or more)
will be able to generate a schema for you. Then you can just adjust
that schema as you like. One such tool is TRANG that is also integrated
through a GUI in oXygen:
http://www.thaiopensource.com/relaxng/trang.html

For instance on your sample file it gives the following XML Schema:

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified">
<xs:element name="docDefinition">
<xs:complexType>
<xs:sequence>
<xs:element ref="tagDefinition"/>
</xs:sequence>
<xs:attribute name="id" use="required" type="xs:integer"/>
</xs:complexType>
</xs:element>
<xs:element name="tagDefinition">
<xs:complexType>
<xs:sequence>
<xs:element ref="attribute"/>
</xs:sequence>
<xs:attribute name="id" use="required" type="xs:integer"/>
<xs:attribute name="label" use="required" type="xs:NCName"/>
<xs:attribute name="tagName" use="required" type="xs:NCName"/>
</xs:complexType>
</xs:element>
<xs:element name="attribute">
<xs:complexType>
<xs:sequence>
<xs:element maxOccurs="unbounded" ref="value"/>
</xs:sequence>
<xs:attribute name="id" use="required" type="xs:integer"/>
<xs:attribute name="label" use="required" type="xs:NCName"/>
<xs:attribute name="name" use="required" type="xs:NCName"/>
<xs:attribute name="type" use="required" type="xs:NCName"/>
</xs:complexType>
</xs:element>
<xs:element name="value">
<xs:complexType>
<xs:simpleContent>
<xs:extension base="xs:NCName">
<xs:attribute name="id" use="required" type="xs:integer"/>
<xs:attribute name="label" use="required"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:element>
</xs:schema>

Best Regards,
George
 
F

fedro

Thanks George, that's a nice tool. I used it for the XML-Document and
so i can skip that <docDefinition/> Part.

The problem with "labeling" (thats needed for the user-interface) i
solved as follows:

<xsd:element name="docDefinition">

<!--manual insert start-->
<xsd:annotation>
<xsd:appinfo>
<label name="DataStructure"/>
</xsd:appinfo>
</xsd:annotation>
<!--manual insert stop-->

<xsd:complexType>
<xsd:sequence>
<xsd:element maxOccurs="unbounded" ref="tagDefinition"/>
</xsd:sequence>
<xsd:attribute name="id" type="xsd:integer" use="required"/>
</xsd:complexType>
</xsd:element>




Cheers, Dominik
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,994
Messages
2,570,222
Members
46,810
Latest member
Kassie0918

Latest Threads

Top