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 id0/id nameProduct #0/name descriptionThis 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:[EMAIL PROTECTED] 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 [EMAIL PROTECTED] 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: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [C++] XMLDocument has no root object
I'll take a look at this. On 16/05/07, Andy Grove [EMAIL PROTECTED] 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 id0/id nameProduct #0/name descriptionThis 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:[EMAIL PROTECTED] 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 [EMAIL PROTECTED] 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: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- Pete
Re: [C++] XMLDocument has no root object
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 [EMAIL PROTECTED] wrote: I'll take a look at this. On 16/05/07, Andy Grove [EMAIL PROTECTED] 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 id0/id nameProduct #0/name descriptionThis 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:[EMAIL PROTECTED] 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 [EMAIL PROTECTED] 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: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- Pete -- Pete
Re: [C++] XMLDocument has no root object
On 17/05/07, Pete Robbins [EMAIL PROTECTED] 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 [EMAIL PROTECTED] wrote: I'll take a look at this. On 16/05/07, Andy Grove [EMAIL PROTECTED] 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 id0/id nameProduct #0/name descriptionThis 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:[EMAIL PROTECTED] 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 [EMAIL PROTECTED] 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: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- Pete -- Pete -- Pete
[C++] XMLDocument has no root object
I am trying to parse an XML document using Tuscany C++ (current build). The XMLHelper::loadFile() method is returning an XMLDocumentPtr and no exceptions are thrown. However, a call to XMLDocument::getRootDataObject() returns NULL. This is the code that I am using. cout START endl; const char *filename = input.xml; XMLDocumentPtr doc = xmlHelper-loadFile( filename ); if (!doc) { cout FAILED TO PARSE endl; } DataObjectPtr root = doc-getRootDataObject(); if (!root) { cout NO ROOT OBJECT endl; } cout END endl; This produces the output: START NO ROOT OBJECT END Any guidance would be much appreciated. Thanks, Andy. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [C++] XMLDocument has no root object
On 27/04/07, Andy Grove [EMAIL PROTECTED] wrote: I am trying to parse an XML document using Tuscany C++ (current build). The XMLHelper::loadFile() method is returning an XMLDocumentPtr and no exceptions are thrown. However, a call to XMLDocument::getRootDataObject() returns NULL. What do you see if you print the XMLDocument ? -- Caroline
RE: [C++] XMLDocument has no root object
Hi Caroline, If I call xmlHelper-save(doc) I just get the prolog e.g. ?xml version=1.0 encoding=UTF-8? and no content. I've tried with a couple of different input documents and I have also confirmed that I do get an exception if the input document doesn't exist. Thanks, Andy. -Original Message- From: Caroline Maynard [mailto:[EMAIL PROTECTED] Sent: 27 April 2007 14:34 To: tuscany-dev@ws.apache.org Subject: Re: [C++] XMLDocument has no root object On 27/04/07, Andy Grove [EMAIL PROTECTED] wrote: I am trying to parse an XML document using Tuscany C++ (current build). The XMLHelper::loadFile() method is returning an XMLDocumentPtr and no exceptions are thrown. However, a call to XMLDocument::getRootDataObject() returns NULL. What do you see if you print the XMLDocument ? -- Caroline - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: [C++] XMLDocument has no root object
I've tried with a few input documents and I even get the problem with this very simple xml. I'm not using schema - is that a problem? ?xml version=1.0 encoding=UTF-8? test xmlns=http://www.example.com/; something/ /test Thanks, Andy. -Original Message- From: Caroline Maynard [mailto:[EMAIL PROTECTED] Sent: 27 April 2007 16:23 To: tuscany-dev@ws.apache.org Subject: Re: [C++] XMLDocument has no root object On 27/04/07, Andy Grove [EMAIL PROTECTED] wrote: Hi Caroline, If I call xmlHelper-save(doc) I just get the prolog e.g. ?xml version=1.0 encoding=UTF-8? and no content. I've tried with a couple of different input documents and I have also confirmed that I do get an exception if the input document doesn't exist. I've had this happen too, and it was because the document wasn't valid against the schema. The symptoms were as you describe. In my case ( http://www.mail-archive.com/tuscany-dev@ws.apache.org/msg10937.html) the circumstances were a bit different, but probably something is amiss with your input and libxml2 isn't kind enough to tell you. Can you try pushing them through an XML validator? -- Caroline - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [C++] XMLDocument has no root object
On 27/04/07, Andy Grove [EMAIL PROTECTED] wrote: I'm not using schema - is that a problem? Ah. Welcome to https://issues.apache.org/jira/browse/TUSCANY-747 -- Caroline