You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tuscany.apache.org by Andy Grove <gr...@roguewave.com> on 2007/05/16 17:11:10 UTC

RE: [C++] XMLDocument has no root object

I'm now trying to parse a document that does have a schema and I'm still
running into the same problem - my document has no root object and no
root element name.

Any help figuring out why this isn't working would be very much
appreciated. I'm running this on a Windows platform. Source code and XML
/ XSD below.

Thanks,

Andy.

--------------------------------------

C++ source code:

DataFactoryPtr myDf = DataFactory::getDataFactory();
XSDHelperPtr helper = HelperProvider::getXSDHelper(myDf);
helper->defineFile( "catalog.xsd" );
XMLDocumentPtr doc = xmlHelper->loadFile( "catalog.xml" );
DataObjectPtr root = doc->getRootDataObject();
if (!root) {
	fprintf(stderr, "NO ROOT\n"); fflush(stderr); // this *is*
output to the console
}

XML document:

<catalog xmlns="http://www.roguewave.com/uri/catalog/"
xsi:schemaLocation="http://www.roguewave.com/uri/catalog/ catalog.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<product>
<id>0</id>
<name>Product #0</name>
<description>This is the description for product #0</description>
</product>
</catalog>

XML schema:

<?xml version="1.0" encoding="ISO-8859-1" ?>
<xs:schema 
    xmlns:xs="http://www.w3.org/2001/XMLSchema" 
    targetNamespace="http://www.roguewave.com/uri/catalog/"
    elementFormDefault="qualified">

<xs:element name="catalog">
 <xs:complexType>
  <xs:sequence>
   <xs:element name="product" maxOccurs="unbounded">
    <xs:complexType>
     <xs:sequence>
      <xs:element name="id" type="xs:string"/>
      <xs:element name="name" type="xs:string"/>
      <xs:element name="description" type="xs:string"/>
     </xs:sequence>
    </xs:complexType>
   </xs:element>
  </xs:sequence>
 </xs:complexType>
</xs:element>

</xs:schema>
 

-----Original Message-----
From: Caroline Maynard [mailto:caroline.maynard@gmail.com] 
Sent: 27 April 2007 16:41
To: tuscany-dev@ws.apache.org
Subject: Re: [C++] XMLDocument has no root object

On 27/04/07, Andy Grove <gr...@roguewave.com> wrote:
>
>
> I'm not using schema - is that a problem?



Ah. Welcome to https://issues.apache.org/jira/browse/TUSCANY-747

--
Caroline

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


Re: [C++] XMLDocument has no root object

Posted by Pete Robbins <ro...@googlemail.com>.
On 17/05/07, Pete Robbins <ro...@googlemail.com> wrote:

> OK... sorted. The problem is that your schema targetNamespace is "http://www.roguewave.com/uri/catalog/
> " but the document namspace uri is "http://www.roguewave.com/uri/catalog/"
>
> Spot the difference? There is a space at the end of the schema
> targetNamespace so they do not match! I guess the question is should
> trailing (or leading) spaces be ignored?
>




Answers own question: Spaces are allowed in the anyURI type (but
discouraged) so the handling by the SDOC C++ code is correct.



>
> Cheers,
>
>  On 16/05/07, Pete Robbins <ro...@googlemail.com> wrote:
> >
> > I'll take a look at this.
> >
> > On 16/05/07, Andy Grove <grove@roguewave.com > wrote:
> > >
> > >
> > > I'm now trying to parse a document that does have a schema and I'm
> > > still
> > > running into the same problem - my document has no root object and no
> > > root element name.
> > >
> > > Any help figuring out why this isn't working would be very much
> > > appreciated. I'm running this on a Windows platform. Source code and
> > > XML
> > > / XSD below.
> > >
> > > Thanks,
> > >
> > > Andy.
> > >
> > > --------------------------------------
> > >
> > > C++ source code:
> > >
> > > DataFactoryPtr myDf = DataFactory::getDataFactory();
> > > XSDHelperPtr helper = HelperProvider::getXSDHelper(myDf);
> > > helper->defineFile( " catalog.xsd" );
> > > XMLDocumentPtr doc = xmlHelper->loadFile( "catalog.xml" );
> >
> >
> > >>> Whre/how is xmlHelper defined? I'd expect a line:
> > XMLHelperPtr xmlHelper = HelperProvider::getXMLHelper(myDf);
> >
> > DataObjectPtr root = doc->getRootDataObject();
> > > if (!root) {
> > >        fprintf(stderr, "NO ROOT\n"); fflush(stderr); // this *is*
> > > output to the console
> > > }
> > >
> > > XML document:
> > >
> > > <catalog xmlns="http://www.roguewave.com/uri/catalog/ "
> > > xsi:schemaLocation=" http://www.roguewave.com/uri/catalog/ catalog.xsd
> > > "
> > > xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
> > > <product>
> > > <id>0</id>
> > > <name>Product #0</name>
> > > <description>This is the description for product #0</description>
> > > </product>
> > > </catalog>
> > >
> > > XML schema:
> > >
> > > <?xml version="1.0" encoding="ISO-8859-1" ?>
> > > <xs:schema
> > >    xmlns:xs="http://www.w3.org/2001/XMLSchema"
> > >    targetNamespace=" http://www.roguewave.com/uri/catalog/ "
> > >    elementFormDefault="qualified">
> > >
> > > <xs:element name="catalog">
> > > <xs:complexType>
> > > <xs:sequence>
> > >   <xs:element name="product" maxOccurs="unbounded">
> > >    <xs:complexType>
> > >     <xs:sequence>
> > >      <xs:element name="id" type="xs:string"/>
> > >      <xs:element name="name" type="xs:string"/>
> > >      <xs:element name="description" type="xs:string"/>
> > >     </xs:sequence>
> > >    </xs:complexType>
> > >   </xs:element>
> > > </xs:sequence>
> > > </xs:complexType>
> > > </xs:element>
> > >
> > > </xs:schema>
> > >
> > >
> > > -----Original Message-----
> > > From: Caroline Maynard [mailto:caroline.maynard@gmail.com]
> > > Sent: 27 April 2007 16:41
> > > To: tuscany-dev@ws.apache.org
> > > Subject: Re: [C++] XMLDocument has no root object
> > >
> > > On 27/04/07, Andy Grove < grove@roguewave.com> wrote:
> > > >
> > > >
> > > > I'm not using schema - is that a problem?
> > >
> > >
> > >
> > > Ah. Welcome to https://issues.apache.org/jira/browse/TUSCANY-747
> > >
> > > --
> > > Caroline
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: tuscany-dev-unsubscribe@ws.apache.org
> > > For additional commands, e-mail: tuscany-dev-help@ws.apache.org
> > >
> > >
> >
> >
> > --
> > Pete
>
>
>
>
> --
> Pete




-- 
Pete

Re: [C++] XMLDocument has no root object

Posted by Pete Robbins <ro...@googlemail.com>.
OK... sorted. The problem is that your schema targetNamespace is
"http://www.roguewave.com/uri/catalog/
" but the document namspace uri is "http://www.roguewave.com/uri/catalog/"

Spot the difference? There is a space at the end of the schema
targetNamespace so they do not match! I guess the question is should
trailing (or leading) spaces be ignored?

Cheers,

On 16/05/07, Pete Robbins <ro...@googlemail.com> wrote:
>
> I'll take a look at this.
>
> On 16/05/07, Andy Grove <gr...@roguewave.com> wrote:
> >
> >
> > I'm now trying to parse a document that does have a schema and I'm still
> > running into the same problem - my document has no root object and no
> > root element name.
> >
> > Any help figuring out why this isn't working would be very much
> > appreciated. I'm running this on a Windows platform. Source code and XML
> > / XSD below.
> >
> > Thanks,
> >
> > Andy.
> >
> > --------------------------------------
> >
> > C++ source code:
> >
> > DataFactoryPtr myDf = DataFactory::getDataFactory();
> > XSDHelperPtr helper = HelperProvider::getXSDHelper(myDf);
> > helper->defineFile( " catalog.xsd" );
> > XMLDocumentPtr doc = xmlHelper->loadFile( "catalog.xml" );
>
>
> >>> Whre/how is xmlHelper defined? I'd expect a line:
> XMLHelperPtr xmlHelper = HelperProvider::getXMLHelper(myDf);
>
> DataObjectPtr root = doc->getRootDataObject();
> > if (!root) {
> >        fprintf(stderr, "NO ROOT\n"); fflush(stderr); // this *is*
> > output to the console
> > }
> >
> > XML document:
> >
> > <catalog xmlns="http://www.roguewave.com/uri/catalog/"
> > xsi:schemaLocation=" http://www.roguewave.com/uri/catalog/ catalog.xsd"
> > xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
> > <product>
> > <id>0</id>
> > <name>Product #0</name>
> > <description>This is the description for product #0</description>
> > </product>
> > </catalog>
> >
> > XML schema:
> >
> > <?xml version="1.0" encoding="ISO-8859-1" ?>
> > <xs:schema
> >    xmlns:xs="http://www.w3.org/2001/XMLSchema"
> >    targetNamespace="http://www.roguewave.com/uri/catalog/ "
> >    elementFormDefault="qualified">
> >
> > <xs:element name="catalog">
> > <xs:complexType>
> > <xs:sequence>
> >   <xs:element name="product" maxOccurs="unbounded">
> >    <xs:complexType>
> >     <xs:sequence>
> >      <xs:element name="id" type="xs:string"/>
> >      <xs:element name="name" type="xs:string"/>
> >      <xs:element name="description" type="xs:string"/>
> >     </xs:sequence>
> >    </xs:complexType>
> >   </xs:element>
> > </xs:sequence>
> > </xs:complexType>
> > </xs:element>
> >
> > </xs:schema>
> >
> >
> > -----Original Message-----
> > From: Caroline Maynard [mailto:caroline.maynard@gmail.com]
> > Sent: 27 April 2007 16:41
> > To: tuscany-dev@ws.apache.org
> > Subject: Re: [C++] XMLDocument has no root object
> >
> > On 27/04/07, Andy Grove <gr...@roguewave.com> wrote:
> > >
> > >
> > > I'm not using schema - is that a problem?
> >
> >
> >
> > Ah. Welcome to https://issues.apache.org/jira/browse/TUSCANY-747
> >
> > --
> > Caroline
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: tuscany-dev-unsubscribe@ws.apache.org
> > For additional commands, e-mail: tuscany-dev-help@ws.apache.org
> >
> >
>
>
> --
> Pete




-- 
Pete

Re: [C++] XMLDocument has no root object

Posted by Pete Robbins <ro...@googlemail.com>.
I'll take a look at this.

On 16/05/07, Andy Grove <gr...@roguewave.com> wrote:
>
>
> I'm now trying to parse a document that does have a schema and I'm still
> running into the same problem - my document has no root object and no
> root element name.
>
> Any help figuring out why this isn't working would be very much
> appreciated. I'm running this on a Windows platform. Source code and XML
> / XSD below.
>
> Thanks,
>
> Andy.
>
> --------------------------------------
>
> C++ source code:
>
> DataFactoryPtr myDf = DataFactory::getDataFactory();
> XSDHelperPtr helper = HelperProvider::getXSDHelper(myDf);
> helper->defineFile( "catalog.xsd" );
> XMLDocumentPtr doc = xmlHelper->loadFile( "catalog.xml" );


>>> Whre/how is xmlHelper defined? I'd expect a line:
XMLHelperPtr xmlHelper = HelperProvider::getXMLHelper(myDf);

DataObjectPtr root = doc->getRootDataObject();
> if (!root) {
>        fprintf(stderr, "NO ROOT\n"); fflush(stderr); // this *is*
> output to the console
> }
>
> XML document:
>
> <catalog xmlns="http://www.roguewave.com/uri/catalog/"
> xsi:schemaLocation="http://www.roguewave.com/uri/catalog/ catalog.xsd"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
> <product>
> <id>0</id>
> <name>Product #0</name>
> <description>This is the description for product #0</description>
> </product>
> </catalog>
>
> XML schema:
>
> <?xml version="1.0" encoding="ISO-8859-1" ?>
> <xs:schema
>    xmlns:xs="http://www.w3.org/2001/XMLSchema"
>    targetNamespace="http://www.roguewave.com/uri/catalog/"
>    elementFormDefault="qualified">
>
> <xs:element name="catalog">
> <xs:complexType>
> <xs:sequence>
>   <xs:element name="product" maxOccurs="unbounded">
>    <xs:complexType>
>     <xs:sequence>
>      <xs:element name="id" type="xs:string"/>
>      <xs:element name="name" type="xs:string"/>
>      <xs:element name="description" type="xs:string"/>
>     </xs:sequence>
>    </xs:complexType>
>   </xs:element>
> </xs:sequence>
> </xs:complexType>
> </xs:element>
>
> </xs:schema>
>
>
> -----Original Message-----
> From: Caroline Maynard [mailto:caroline.maynard@gmail.com]
> Sent: 27 April 2007 16:41
> To: tuscany-dev@ws.apache.org
> Subject: Re: [C++] XMLDocument has no root object
>
> On 27/04/07, Andy Grove <gr...@roguewave.com> wrote:
> >
> >
> > I'm not using schema - is that a problem?
>
>
>
> Ah. Welcome to https://issues.apache.org/jira/browse/TUSCANY-747
>
> --
> Caroline
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tuscany-dev-unsubscribe@ws.apache.org
> For additional commands, e-mail: tuscany-dev-help@ws.apache.org
>
>


-- 
Pete