Yes Andy, I agree it's compliant although I think that the spec does also
alow an implementation to optimize the handling of this. But, I'm not so
sure that's such a great idea and if it should be accomodated in the CTS.
For now, I'm fine with checking in the new test, below.
Thanks,
Frank.
"Andy Grove" <[EMAIL PROTECTED]> wrote on 04/25/2007 11:39:56 AM:
>
> Thanks Frank. So the simple/mixed content is accessed via the Sequence
> API rather than by a special property. This makes sense to me now.
>
> Here's a test case that passes against Tuscany for the example XML. This
> actually seems to be spec-compliant. Would you agree? If so, I'll file a
> JIRA to get this added to the CTS.
>
> public void testComplexElementWithSimpleContent() {
> String xml = "<root xmlns=\"http://test/\"><name
> lang=\"en_US\">Adam</name></root>";
> XMLDocument doc = XMLHelper.INSTANCE.load( xml );
> DataObject root = doc.getRootObject();
> Property nameProperty = root.getProperty( "name" );
> assertEquals( "commonj.sdo", nameProperty.getType().getURI() );
> assertEquals( "DataObject", nameProperty.getType().getName() );
> DataObject dobj = root.getDataObject( "name.0" );
> assertEquals( "en_US", dobj.getString( "lang" ) );
> assertEquals( "Adam", dobj.getSequence().getValue(0) );
> }
>
> Thanks,
>
> Andy.
>
> -----Original Message-----
> From: Frank Budinsky [mailto:[EMAIL PROTECTED]
> Sent: 25 April 2007 15:00
> To: [email protected]
> Subject: Re: How can I process this XML with Tuscany?
>
> Hi Andy,
>
> In Tuscany, I believe it currently works like this:
>
> The root object is an open, sequenced, mixed type. The name property is
> type String (I believe) but it isMany=true, that's why you get a List (
> org.eclipse.emf.ecore.util.FeatureMapUtil$FeatureEList) back from get().
>
> You should be able to get the name by calling:
>
> String name = (String)root.getList("name").get(0);
>
> The simple content would appear as mixed text:
>
> String textContent = root.getSequence().getValue(0);
>
> I'm not sure if this is quite right according to the spec.
>
> I'm not sure that the "value" property is the the right approach in this
> case, since we would need to parse the entire document to be sure that
> all instances have simple content. The Tuscany approach works the same
> in the more general case like this:
>
> <root xmlns="http://test/">
> <name lang="en_US">Adam</name>
> <name lang="en_US">Adam<junk>abc<junk>Smith</name>
> </root>
>
> Frank.
>
>
> "Andy Grove" <[EMAIL PROTECTED]> wrote on 04/25/2007 07:06:13 AM:
>
> > This is partly a Tuscany implementation question, and partly a CTS /
> > specification question.
> >
> > I have the following XML document and there is no XSD defined.
> >
> > <root xmlns="http://test/"><name lang="en_US">Adam</name></root>
> >
> > If I use XMLHelper to load the document and then run this code ...
> >
> > Property nameProp = root.getInstanceProperty( "name" );
> > Object name = root.get( nameProp );
> >
> > I get an "org.eclipse.emf.ecore.util.FeatureMapUtil$FeatureEList"
> > object returned, which does not appear to implement any SDO
> interfaces.
> >
> > Does Tuscany provide a way to get the simple content of the "name"
> > element as well as the "lang" attribute?
> >
> > From reading the 2.1 specification, my understanding is that "name"
> > should be a DataObject with a "lang" property representing the
> > attribute and a special "value" property representing the simple
> > content. Will Tuscany be supporting this 2.1 feature?
> >
> > Thanks,
> >
> > Andy.
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]