You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tuscany.apache.org by Caroline Maynard <ce...@php.net> on 2006/11/17 13:59:56 UTC

[SDO C++] Root data object is null after serializing

I have a problem report from an SDO for PHP user which I'd like to 
discuss. You can read it at http://pecl.php.net/bugs/bug.php?id=9339, 
but here's what happens. The schema is:

<?xml version="1.0" encoding="UTF-8"?>
    <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" <http://www.w3.org/2001/XMLSchema%22> 
      targetNamespace="http://AnnotationTest" <http://AnnotationTest%22>>
      <xs:element name="testTriggerEvent">
        <xs:complexType>
          <xs:sequence>
          </xs:sequence>
        </xs:complexType>
      </xs:element>
    </xs:schema>

We create a DataFactory and do a define using the above schema. Then use 
the DataFactory to create an XMLDocument of type testTriggerEvent. So 
the XMLDocument looks like:

<?xml version="1.0" encoding="UTF-8"?>
<testTriggerEvent xmlns="http://AnnotationTest" 
xmlns:tns="http://AnnotationTest"/>

At this time we can do a XMLDocument::getRootDataObject() which returns 
a rather uninteresting SDO without any properties.

Now we serialize the model  (by doing getTypes() on the DataFactory and 
passing the result into XSDHelper::generate()), and the document. The 
serialized model comes out as:

<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
xmlns:sdo="commonj.sdo"  
        xmlns:sdoxml="commonj.sdo/xml">
  <xsd:element name="rootType" type="RootType"/>
  <xsd:complexType name="RootType">
    <xsd:sequence>
      <xsd:element name="testTriggerEvent" type="testTriggerEvent" 
minOccurs="0"/>
    </xsd:sequence>
  </xsd:complexType>
<xsd:element name="testTriggerEvent " type="testTriggerEvent"/>
<xsd:complexType name="testTriggerEvent"/>
</xsd:schema>

Then we propagate the serialized model and the document and attempt to 
unserialize it, by creating a DataFactory and using XSDHelper::define(), 
followed by XMLHelper::load() to reconstruct the XMLDocument. These 
apparently work OK, but then XMLDocument::getRootDataObject() returns null.

This may seem like a pathological case, but there are sound reasons for 
doing it. I'm just not sure where the problem lies - is it the 
reconstruction of the XMLDocument, or is the serialized model wrong? Is 
there an alternative way to code the "empty" element which would get the 
desired outcome?


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


Re: [SDO C++] Root data object is null after serializing

Posted by Pete Robbins <ro...@googlemail.com>.
Ok I'll check to see where a regression could have crept in.

On 17/11/06, Caroline Maynard <ca...@gmail.com> wrote:
>
> Thanks, that was helpful. I've fixed up the serialization so that it pulls
> the URI from the type of the data object we're serializing, and it's now
> getting through OK. The generated schema looks much more appealing:
> <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
>    xmlns:sdo="commonj.sdo" xmlns:sdoxml="commonj.sdo/xml"
>    xmlns:tns="http://AnnotationTest" targetNamespace="
> http://AnnotationTest
> ">
> <xsd:element name="testTriggerEvent" type="testTriggerEvent"/>
> <xsd:complexType name="testTriggerEvent"/>
> </xsd:schema>
>
> I think this may be a regression, perhaps introduced with the string
> changes, because the php code hasn't changed for a while, and it has
> always
> passed in a NULL and the Right Thing used to happen.
>
> I hadn't considered that an XMLDocument might validly have no root data
> object, but I've put in a check for this in unserialize, and probably need
> one in some other places too.
>
> On 17/11/06, Pete Robbins <ro...@googlemail.com> wrote:
> >
> > Looks from the code that you have to specify the targetNamespace on the
> > XSDHelper::generate() call
> >
>
> (sorry about the wacky formatting in my first msg, btw. It was supposed to
> be plain text :-( )



Perfectly formatted in Gmail!

--
> Caroline
>
>


-- 
Pete

Re: [SDO C++] Root data object is null after serializing

Posted by Caroline Maynard <ca...@gmail.com>.
Thanks, that was helpful. I've fixed up the serialization so that it pulls
the URI from the type of the data object we're serializing, and it's now
getting through OK. The generated schema looks much more appealing:
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    xmlns:sdo="commonj.sdo" xmlns:sdoxml="commonj.sdo/xml"
    xmlns:tns="http://AnnotationTest" targetNamespace="http://AnnotationTest
">
<xsd:element name="testTriggerEvent" type="testTriggerEvent"/>
<xsd:complexType name="testTriggerEvent"/>
</xsd:schema>

I think this may be a regression, perhaps introduced with the string
changes, because the php code hasn't changed for a while, and it has always
passed in a NULL and the Right Thing used to happen.

I hadn't considered that an XMLDocument might validly have no root data
object, but I've put in a check for this in unserialize, and probably need
one in some other places too.

On 17/11/06, Pete Robbins <ro...@googlemail.com> wrote:
>
> Looks from the code that you have to specify the targetNamespace on the
> XSDHelper::generate() call
>

(sorry about the wacky formatting in my first msg, btw. It was supposed to
be plain text :-( )
-- 
Caroline

Re: [SDO C++] Root data object is null after serializing

Posted by Pete Robbins <ro...@googlemail.com>.
Looks from the code that you have to specify the targetNamespace on the
XSDHelper::generate() call

On 17/11/06, Pete Robbins <ro...@googlemail.com> wrote:
>
> The generated schema is missing the targetNamespace so the types don't
> have one! The document has the element testTriggerEvent belonging to
> http://AnnotationTest <http://annotationtest/> so that doesn't match
> anything in the model when you reloaded the generated schema..
>
> Now to find out why the tns wasn't generated...
>
> Cheers,
>
>
>  On 17/11/06, Caroline Maynard <ce...@php.net> wrote:
> >
> > I have a problem report from an SDO for PHP user which I'd like to
> > discuss. You can read it at http://pecl.php.net/bugs/bug.php?id=9339,
> > but here's what happens. The schema is:
> >
> > <?xml version="1.0" encoding="UTF-8"?>
> >    <xs:schema xmlns:xs=" http://www.w3.org/2001/XMLSchema" <
> > http://www.w3.org/2001/XMLSchema%22>
> >      targetNamespace="http://AnnotationTest <http://annotationtest/> " <
> > http://AnnotationTest%22 <http://annotationtest%22/>>>
> >      <xs:element name="testTriggerEvent">
> >        <xs:complexType>
> >          <xs:sequence>
> >          </xs:sequence>
> >        </xs:complexType>
> >      </xs:element>
> >    </xs:schema>
> >
> > We create a DataFactory and do a define using the above schema. Then use
> > the DataFactory to create an XMLDocument of type testTriggerEvent. So
> > the XMLDocument looks like:
> >
> > <?xml version="1.0" encoding="UTF-8"?>
> > <testTriggerEvent xmlns="http://AnnotationTest <http://annotationtest/>"
> > xmlns:tns=" http://AnnotationTest <http://annotationtest/>"/>
> >
> > At this time we can do a XMLDocument::getRootDataObject() which returns
> > a rather uninteresting SDO without any properties.
> >
> > Now we serialize the model  (by doing getTypes() on the DataFactory and
> > passing the result into XSDHelper::generate()), and the document. The
> > serialized model comes out as:
> >
> > <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema "
> > xmlns:sdo="commonj.sdo"
> >        xmlns:sdoxml="commonj.sdo/xml">
> > <xsd:element name="rootType" type="RootType"/>
> > <xsd:complexType name="RootType">
> >    <xsd:sequence>
> >      <xsd:element name="testTriggerEvent" type="testTriggerEvent"
> > minOccurs="0"/>
> >    </xsd:sequence>
> > </xsd:complexType>
> > <xsd:element name="testTriggerEvent " type="testTriggerEvent"/>
> > <xsd:complexType name="testTriggerEvent"/>
> > </xsd:schema>
> >
> > Then we propagate the serialized model and the document and attempt to
> > unserialize it, by creating a DataFactory and using XSDHelper::define(),
> >
> > followed by XMLHelper::load() to reconstruct the XMLDocument. These
> > apparently work OK, but then XMLDocument::getRootDataObject() returns
> > null.
> >
> > This may seem like a pathological case, but there are sound reasons for
> > doing it. I'm just not sure where the problem lies - is it the
> > reconstruction of the XMLDocument, or is the serialized model wrong? Is
> > there an alternative way to code the "empty" element which would get the
> >
> > desired outcome?
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: tuscany-dev-unsubscribe@ws.apache.org
> > For additional commands, e-mail: tuscany-dev-help@ws.apache.org
> >
> >
>
>
> --
> Pete




-- 
Pete

Re: [SDO C++] Root data object is null after serializing

Posted by Pete Robbins <ro...@googlemail.com>.
The generated schema is missing the targetNamespace so the types don't have
one! The document has the element testTriggerEvent belonging to
http://AnnotationTest so that doesn't match anything in the model when you
reloaded the generated schema..

Now to find out why the tns wasn't generated...

Cheers,


On 17/11/06, Caroline Maynard <ce...@php.net> wrote:
>
> I have a problem report from an SDO for PHP user which I'd like to
> discuss. You can read it at http://pecl.php.net/bugs/bug.php?id=9339,
> but here's what happens. The schema is:
>
> <?xml version="1.0" encoding="UTF-8"?>
>    <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" <
> http://www.w3.org/2001/XMLSchema%22>
>      targetNamespace="http://AnnotationTest" <http://AnnotationTest%22>>
>      <xs:element name="testTriggerEvent">
>        <xs:complexType>
>          <xs:sequence>
>          </xs:sequence>
>        </xs:complexType>
>      </xs:element>
>    </xs:schema>
>
> We create a DataFactory and do a define using the above schema. Then use
> the DataFactory to create an XMLDocument of type testTriggerEvent. So
> the XMLDocument looks like:
>
> <?xml version="1.0" encoding="UTF-8"?>
> <testTriggerEvent xmlns="http://AnnotationTest"
> xmlns:tns="http://AnnotationTest"/>
>
> At this time we can do a XMLDocument::getRootDataObject() which returns
> a rather uninteresting SDO without any properties.
>
> Now we serialize the model  (by doing getTypes() on the DataFactory and
> passing the result into XSDHelper::generate()), and the document. The
> serialized model comes out as:
>
> <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
> xmlns:sdo="commonj.sdo"
>        xmlns:sdoxml="commonj.sdo/xml">
> <xsd:element name="rootType" type="RootType"/>
> <xsd:complexType name="RootType">
>    <xsd:sequence>
>      <xsd:element name="testTriggerEvent" type="testTriggerEvent"
> minOccurs="0"/>
>    </xsd:sequence>
> </xsd:complexType>
> <xsd:element name="testTriggerEvent " type="testTriggerEvent"/>
> <xsd:complexType name="testTriggerEvent"/>
> </xsd:schema>
>
> Then we propagate the serialized model and the document and attempt to
> unserialize it, by creating a DataFactory and using XSDHelper::define(),
> followed by XMLHelper::load() to reconstruct the XMLDocument. These
> apparently work OK, but then XMLDocument::getRootDataObject() returns
> null.
>
> This may seem like a pathological case, but there are sound reasons for
> doing it. I'm just not sure where the problem lies - is it the
> reconstruction of the XMLDocument, or is the serialized model wrong? Is
> there an alternative way to code the "empty" element which would get the
> desired outcome?
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tuscany-dev-unsubscribe@ws.apache.org
> For additional commands, e-mail: tuscany-dev-help@ws.apache.org
>
>


-- 
Pete