You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commons-dev@ws.apache.org by Anamitra Bhattacharyya <ab...@us.ibm.com> on 2009/02/26 16:42:28 UTC
how to parse multiple schema docs using XmlSchemaCollection api
Hi
I am new to xml schema [have used xml beans before and am trying to move to
xml schema] and I am wondering is there is an api to parse multiple schema
documents together to get composite schema model. This is critical as a
WSDL doc can contain dependent schema definitions defined as below
<types>
<xs:schema>
.......
</xs:schema>
<xs:schema>>
.......
</xs:schema>
</types>
The xml schema tutorial shows parsing a single schema document
InputStream is = new FileInputStream(fileName);
XmlSchemaCollection schemaCol = new XmlSchemaCollection();
XmlSchema schema = schemaCol.read(new StreamSource(is), null);
and if I read through the XMLSchemaCollection api - I only see apis like
read(Element,..) =>only dealing with one schema at a time. Can anyone pls
give an example how I can get to parse the schema from the above wsdl
snippet. In xmlbeans I used to do this
for(String schemaDoc:schemaList)
{
schemas[i] = XmlObject.Factory.parse(schemaDoc,
(new XmlOptions()).setLoadLineNumbers
().setLoadMessageDigest());
...
}
SchemaTypeSystem sts = XmlBeans.compileXsd(schemas, XmlBeans.
getBuiltinTypeSystem(), compileOptions);
I am not able to locate something similar in xml schemas.
Any help is appreciated.
thanks
Anamitra
Re: how to parse multiple schema docs using XmlSchemaCollection api
Posted by Benson Margulies <bi...@gmail.com>.
I think you just keep calling the collection read API for each of the
xs:schema elements.
On Thu, Feb 26, 2009 at 10:42 AM, Anamitra Bhattacharyya
<ab...@us.ibm.com> wrote:
>
> Hi
> I am new to xml schema [have used xml beans before and am trying to move to
> xml schema] and I am wondering is there is an api to parse multiple schema
> documents together to get composite schema model. This is critical as a
> WSDL doc can contain dependent schema definitions defined as below
> <types>
> <xs:schema>
> .......
> </xs:schema>
> <xs:schema>>
> .......
> </xs:schema>
> </types>
>
> The xml schema tutorial shows parsing a single schema document
>
> InputStream is = new FileInputStream(fileName);
> XmlSchemaCollection schemaCol = new XmlSchemaCollection();
> XmlSchema schema = schemaCol.read(new StreamSource(is), null);
>
> and if I read through the XMLSchemaCollection api - I only see apis like
> read(Element,..) =>only dealing with one schema at a time. Can anyone pls
> give an example how I can get to parse the schema from the above wsdl
> snippet. In xmlbeans I used to do this
>
> for(String schemaDoc:schemaList)
> {
>
> schemas[i] = XmlObject.Factory.parse(schemaDoc,
> (new XmlOptions()).setLoadLineNumbers
> ().setLoadMessageDigest());
> ...
> }
> SchemaTypeSystem sts = XmlBeans.compileXsd(schemas, XmlBeans.
> getBuiltinTypeSystem(), compileOptions);
>
> I am not able to locate something similar in xml schemas.
> Any help is appreciated.
>
> thanks
> Anamitra