You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-dev@xerces.apache.org by Hubert Felber <Hu...@abacus.ch> on 2008/10/30 22:25:56 UTC

howto get namespace info from schema

Hello,
 
Please help me with something I got stuck:
I want to get some information out ouf a schema and dont know howto do the following:
 
How do I get the xmlns:po attribute (targetnamespace) out of the following schema
 
<xs:schema
   xmlns:xs="http://www.w3.org/2001/XMLSchema"
   xmlns:po="http://openuri.org/easypo"
   targetNamespace="http://openuri.org/easypo"
   elementFormDefault="qualified">
I figured out that I can retrieve some info with this:
 
targetname space = xsModel.getComponents(XSConstants.TYPE_DEFINITION).item(0).getNamespace();
NamespacesList =  xsModel.getNamespaces()
but I cannot find how to get for example the "xmlns:po" attribute for qualified Element names.
 
I want to create an xml and use this for createElementNS()
Creating an XML works, but I need to put in the namespace info from the schema.
Is this the correct way to extract namespace info out of a schema? 
 
Thank you
Hubert
 
 
 
 
 

Re: howto get namespace info from schema

Posted by Hubert Felber <Hu...@abacus.ch>.
Hi Michael,

Thanks for the hint, this did not cross my mind.
I'll do that.

Hubert

>>> Michael Glavassevich <mr...@ca.ibm.com> 31.10.2008 00:24 >>>

Hi Hubert,

XSModel is a model of the schema components [1] defined by the XML schema
specification. The XML representation of the schema is not part of this
model. If you want access to the namespace declarations I suggest you
process the schema document with one of the general purpose XML APIs (e.g.
SAX or DOM) and extract the namespace declarations from there.

Thanks.

[1] http://www.w3.org/TR/xmlschema-1/#components 

Michael Glavassevich
XML Parser Development
IBM Toronto Lab
E-mail: mrglavas@ca.ibm.com 
E-mail: mrglavas@apache.org 

"Hubert Felber" <Hu...@abacus.ch> wrote on 10/30/2008 05:25:56 PM:

> Hello,
>
> Please help me with something I got stuck:
> I want to get some information out ouf a schema and dont know howto
> do the following:
>
> How do I get the xmlns:po attribute (targetnamespace) out of the
> following schema
>
> <xs:schema
>    xmlns:xs="http://www.w3.org/2001/XMLSchema"
>    xmlns:po="http://openuri.org/easypo"
>    targetNamespace="http://openuri.org/easypo"
>    elementFormDefault="qualified">
> I figured out that I can retrieve some info with this:
>
> targetname space = xsModel.getComponents(XSConstants.
> TYPE_DEFINITION).item(0).getNamespace();
> NamespacesList =  xsModel.getNamespaces()
> but I cannot find how to get for example the "xmlns:po" attribute
> for qualified Element names.
>
> I want to create an xml and use this for createElementNS()
> Creating an XML works, but I need to put in the namespace info from
> the schema.
> Is this the correct way to extract namespace info out of a schema?
>
> Thank you
> Hubert


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


Re: howto get namespace info from schema

Posted by Michael Glavassevich <mr...@ca.ibm.com>.
Hi Hubert,

XSModel is a model of the schema components [1] defined by the XML schema
specification. The XML representation of the schema is not part of this
model. If you want access to the namespace declarations I suggest you
process the schema document with one of the general purpose XML APIs (e.g.
SAX or DOM) and extract the namespace declarations from there.

Thanks.

[1] http://www.w3.org/TR/xmlschema-1/#components

Michael Glavassevich
XML Parser Development
IBM Toronto Lab
E-mail: mrglavas@ca.ibm.com
E-mail: mrglavas@apache.org

"Hubert Felber" <Hu...@abacus.ch> wrote on 10/30/2008 05:25:56 PM:

> Hello,
>
> Please help me with something I got stuck:
> I want to get some information out ouf a schema and dont know howto
> do the following:
>
> How do I get the xmlns:po attribute (targetnamespace) out of the
> following schema
>
> <xs:schema
>    xmlns:xs="http://www.w3.org/2001/XMLSchema"
>    xmlns:po="http://openuri.org/easypo"
>    targetNamespace="http://openuri.org/easypo"
>    elementFormDefault="qualified">
> I figured out that I can retrieve some info with this:
>
> targetname space = xsModel.getComponents(XSConstants.
> TYPE_DEFINITION).item(0).getNamespace();
> NamespacesList =  xsModel.getNamespaces()
> but I cannot find how to get for example the "xmlns:po" attribute
> for qualified Element names.
>
> I want to create an xml and use this for createElementNS()
> Creating an XML works, but I need to put in the namespace info from
> the schema.
> Is this the correct way to extract namespace info out of a schema?
>
> Thank you
> Hubert

Re: howto get namespace info from schema

Posted by Michael Glavassevich <mr...@ca.ibm.com>.
Hi Hubert,

XSModel is a model of the schema components [1] defined by the XML schema
specification. The XML representation of the schema is not part of this
model. If you want access to the namespace declarations I suggest you
process the schema document with one of the general purpose XML APIs (e.g.
SAX or DOM) and extract the namespace declarations from there.

Thanks.

[1] http://www.w3.org/TR/xmlschema-1/#components

Michael Glavassevich
XML Parser Development
IBM Toronto Lab
E-mail: mrglavas@ca.ibm.com
E-mail: mrglavas@apache.org

"Hubert Felber" <Hu...@abacus.ch> wrote on 10/30/2008 05:25:56 PM:

> Hello,
>
> Please help me with something I got stuck:
> I want to get some information out ouf a schema and dont know howto
> do the following:
>
> How do I get the xmlns:po attribute (targetnamespace) out of the
> following schema
>
> <xs:schema
>    xmlns:xs="http://www.w3.org/2001/XMLSchema"
>    xmlns:po="http://openuri.org/easypo"
>    targetNamespace="http://openuri.org/easypo"
>    elementFormDefault="qualified">
> I figured out that I can retrieve some info with this:
>
> targetname space = xsModel.getComponents(XSConstants.
> TYPE_DEFINITION).item(0).getNamespace();
> NamespacesList =  xsModel.getNamespaces()
> but I cannot find how to get for example the "xmlns:po" attribute
> for qualified Element names.
>
> I want to create an xml and use this for createElementNS()
> Creating an XML works, but I need to put in the namespace info from
> the schema.
> Is this the correct way to extract namespace info out of a schema?
>
> Thank you
> Hubert