You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-dev@xerces.apache.org by Stefan Brauneis <st...@sit.fraunhofer.de> on 2001/08/30 16:45:37 UTC

Problems using schema and namespaces

Hi all,

I have problems using namespaces and schema together in an application.
To be honest I don't no much about namespaces and schemas yet but have
to learn it. Ok, so what I am looking for is a simple xml-file like
personal-schema.xml and a corresponding xsd-file like personal.xsd but
which both uses also namespaces. Well, I know I could also start and
read the complete schema definition, but I would prefer to look at a
simple example first, so I get an idea what it's all about. Perhaps
somebody has something like that and would be so kind to post it here.


Thanks
    stefan brauneis


---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org


Re: Problems using schema and namespaces

Posted by Stefan Brauneis <st...@sit.fraunhofer.de>.
Hi Alberto,

Thank you very much. That was exactly what I was looking for because all the
other examples I tried before had all some certain type or what so ever that
xercesc 1.5.1 doesn't support. And I can't write an example myself because if
you are not familiar with things you always wonder if it is your fault or the
librarys.

I would suggest to include such an example to xercesc because it shows both:
schema and namespaces. But of course I am just an ordinary user of the library
;-)

Stefan


Alberto Massari wrote:

> At 04:45 PM 8/30/01 +0200, you wrote:
> >Hi all,
> >
> >I have problems using namespaces and schema together in an application.
> >To be honest I don't no much about namespaces and schemas yet but have
> >to learn it. Ok, so what I am looking for is a simple xml-file like
> >personal-schema.xml and a corresponding xsd-file like personal.xsd but
> >which both uses also namespaces. Well, I know I could also start and
> >read the complete schema definition, but I would prefer to look at a
> >simple example first, so I get an idea what it's all about. Perhaps
> >somebody has something like that and would be so kind to post it here.
>
> I think this is what you want:
>
> [personal-schema-namespace.xml]
> <my:personnel xmlns:my="urn:myns"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xsi:schemaLocation="urn:myns personal-namespace.xsd">
>    <my:person id="Big.Boss" >
>      <my:name><my:family>Boss</my:family> <my:given>Big</my:given></my:name>
>      <my:email>chief@foo.com</my:email>
>    </my:person>
> </my:personnel>
>
> [personal-namespace.xsd]
> <schema xmlns='http://www.w3.org/2001/XMLSchema' xmlns:ns="urn:myns"
> targetNamespace="urn:myns">
>
>   <element name="personnel">
>    <complexType>
>     <sequence>
>       <element ref="ns:person" minOccurs='1' maxOccurs='unbounded'/>
>     </sequence>
>    </complexType>
>   </element>
>
>   <element name="person">
>    <complexType>
>     <sequence>
>       <element ref="ns:name"/>
>       <element ref="ns:email" minOccurs='0' maxOccurs='unbounded'/>
>       <element ref="ns:url"   minOccurs='0' maxOccurs='unbounded'/>
>       <element ref="ns:link"  minOccurs='0' maxOccurs='1'/>
>     </sequence>
>     <attribute name="id"  type="ID" use='required'/>
>     <attribute name="note" type="string"/>
>     <attribute name="contr" default="false">
>      <simpleType>
>       <restriction base = "string">
>         <enumeration value="true"/>
>         <enumeration value="false"/>
>       </restriction>
>      </simpleType>
>     </attribute>
>     <attribute name="salary" type="integer"/>
>    </complexType>
>   </element>
>
>   <element name="name">
>    <complexType>
>     <sequence>
>      <element ref="ns:family"/>
>      <element ref="ns:given"/>
>     </sequence>
>    </complexType>
>   </element>
>
>   <element name="family" type='string'/>
>
>   <element name="given" type='string'/>
>
>   <element name="email" type='string'/>
>
>   <element name="url">
>    <complexType>
>     <attribute name="href" type="string" default="http://"/>
>    </complexType>
>   </element>
>
>   <element name="link">
>    <complexType>
>     <attribute name="manager" type="IDREF"/>
>     <attribute name="subordinates" type="IDREFS"/>
>    </complexType>
>   </element>
>
>   <notation name='gif' public='-//APP/Photoshop/4.0' system='photoshop.exe'/>
>
> </schema>
>
> Alberto
>
> -------------------------------
> Alberto Massari
> eXcelon Corp.
> http://www.StylusStudio.com
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
> For additional commands, e-mail: xerces-c-dev-help@xml.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org


Re: Problems using schema and namespaces

Posted by Alberto Massari <al...@exceloncorp.com>.
At 04:45 PM 8/30/01 +0200, you wrote:
>Hi all,
>
>I have problems using namespaces and schema together in an application.
>To be honest I don't no much about namespaces and schemas yet but have
>to learn it. Ok, so what I am looking for is a simple xml-file like
>personal-schema.xml and a corresponding xsd-file like personal.xsd but
>which both uses also namespaces. Well, I know I could also start and
>read the complete schema definition, but I would prefer to look at a
>simple example first, so I get an idea what it's all about. Perhaps
>somebody has something like that and would be so kind to post it here.


I think this is what you want:

[personal-schema-namespace.xml]
<my:personnel xmlns:my="urn:myns" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xsi:schemaLocation="urn:myns personal-namespace.xsd">
   <my:person id="Big.Boss" >
     <my:name><my:family>Boss</my:family> <my:given>Big</my:given></my:name>
     <my:email>chief@foo.com</my:email>
   </my:person>
</my:personnel>

[personal-namespace.xsd]
<schema xmlns='http://www.w3.org/2001/XMLSchema' xmlns:ns="urn:myns" 
targetNamespace="urn:myns">

  <element name="personnel">
   <complexType>
    <sequence>
      <element ref="ns:person" minOccurs='1' maxOccurs='unbounded'/>
    </sequence>
   </complexType>
  </element>

  <element name="person">
   <complexType>
    <sequence>
      <element ref="ns:name"/>
      <element ref="ns:email" minOccurs='0' maxOccurs='unbounded'/>
      <element ref="ns:url"   minOccurs='0' maxOccurs='unbounded'/>
      <element ref="ns:link"  minOccurs='0' maxOccurs='1'/>
    </sequence>
    <attribute name="id"  type="ID" use='required'/>
    <attribute name="note" type="string"/>
    <attribute name="contr" default="false">
     <simpleType>
      <restriction base = "string">
        <enumeration value="true"/>
        <enumeration value="false"/>
      </restriction>
     </simpleType>
    </attribute>
    <attribute name="salary" type="integer"/>
   </complexType>
  </element>

  <element name="name">
   <complexType>
    <sequence>
     <element ref="ns:family"/>
     <element ref="ns:given"/>
    </sequence>
   </complexType>
  </element>

  <element name="family" type='string'/>

  <element name="given" type='string'/>

  <element name="email" type='string'/>

  <element name="url">
   <complexType>
    <attribute name="href" type="string" default="http://"/>
   </complexType>
  </element>

  <element name="link">
   <complexType>
    <attribute name="manager" type="IDREF"/>
    <attribute name="subordinates" type="IDREFS"/>
   </complexType>
  </element>

  <notation name='gif' public='-//APP/Photoshop/4.0' system='photoshop.exe'/>

</schema>

Alberto

-------------------------------
Alberto Massari
eXcelon Corp.
http://www.StylusStudio.com


---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org