Hi, I have the following schema:
<?xml version="1.0" encoding="UTF-8"?> <xs:schema xmlns:ext="urn:Extension" xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="urn:Extension" elementFormDefault="unqualified" attributeFormDefault="unqualified" version="1.0"> <xs:element name="Extension"> <xs:complexType> <xs:sequence> <xs:element ref="ext:SubCategory" minOccurs="0" maxOccurs="unbounded" /> </xs:sequence> </xs:complexType> </xs:element> <xs:element name="SubCategory"> <xs:complexType> <xs:simpleContent> <xs:extension base="xs:string"> <xs:attribute name="displayable" type="xs:boolean" use="optional" /> </xs:extension> </xs:simpleContent> </xs:complexType> </xs:element> </xs:schema> And I'd like to create this xml: <?xml version="1.0" encoding="ASCII"?> <ext:Extension xmlns:ext="urn:Extension"> <ext:SubCategory displayable="true">myCategory</SubCategory> </ext:Extension> I'm having problems setting the value "myCategory". In examples I've seen where the element does not contain an attribute, a simple set("SubCategory", "myCategory") would work. It seems that I can't use that in this case. Here's my current code: HelperContext context = SDOUtil.createHelperContext(); InputStream in = new File("Extension.xsd").toURL().openStream(); context.getXSDHelper().define(in, null); DataObject extension = context.getDataFactory().create("urn:Extension", "Extension"); DataObject subCategory = extension.createDataObject("SubCategory"); subCategory.setBoolean("displayable", true); extension.set("SubCategory", "myCategory"); context.getXMLHelper().save(extension, "urn:Extension", "Extension", System.out); When the set() method is called, i get the following exception: Exception in thread "main" java.lang.ClassCastException: java.lang.String at org.eclipse.emf.ecore.util.EcoreEList.set(EcoreEList.java:448) at org.eclipse.emf.ecore.impl.EStructuralFeatureImpl$InternalSettingDelegateMany.dynamicSet(EStructuralFeatureImpl.java:1647) at org.eclipse.emf.ecore.impl.BasicEObjectImpl.eDynamicSet(BasicEObjectImpl.java:709) at org.apache.tuscany.sdo.impl.DynamicDataObjectImpl.eDynamicSet(DynamicDataObjectImpl.java:159) at org.apache.tuscany.sdo.impl.DataObjectImpl.eSet(DataObjectImpl.java:1459) at org.eclipse.emf.ecore.impl.BasicEObjectImpl.eSet(BasicEObjectImpl.java:654) at org.apache.tuscany.sdo.impl.DataObjectImpl.set(DataObjectImpl.java:142) at org.apache.tuscany.sdo.util.DataObjectUtil.set(DataObjectUtil.java:730) at org.apache.tuscany.sdo.impl.DataObjectImpl.set(DataObjectImpl.java:225) at Test.valueTest(Test.java:186) at Test.main(Test.java:197) I've tried looking through the samples and test cases, but couldn't find a similar example. Any help in pointing me to the correct API would be appreciated. Thanks, -Chris --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
