Chris, we seem to have 3 places where prefixes are generated, and not using the same algorithm.
1) BaseSDOXSDEcoreBuilder.getEPackage() 2) SDOXSDEcoreBuilder.lookupPrefix 3) EMFs BasicExtendedMetadata.computePrefix() The difference in behaviour here is explained by the fact that when the two HelperContexts are used, only one of them is used for the serialization process, and it therefore only has half of the metadata already available. It therefore demand creates metadata, and in so doing creates a prefix using the algorithm at [3], whereas the metadata produced by the XSDHelper.define() operation gets its prefixes (in the end) from [2]. When one HelperContext is used it already has the prefixes generated by [2] available. Is this a significant issue for you? Regards, Kelvin. On 29/05/07, Chris Mildebrandt <[EMAIL PROTECTED]> wrote:
Hello, I'm not sure if this is expected or not, I'll let you guys figure that out. I have the following two schemas: <?xml version="1.0" encoding="UTF-8"?> <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.example.org/Person" xmlns:person="http://www.example.org/Person" elementFormDefault="qualified"> <xsd:element name="Person" type="person:PersonType"></xsd:element> <xsd:complexType name="PersonType"> <xsd:sequence> <xsd:element name="Name" type="xsd:string"></xsd:element> <xsd:element name="Age" type="xsd:string"></xsd:element> <xsd:any namespace="##other" processContents="lax" minOccurs="0" maxOccurs="unbounded"/> </xsd:sequence> <xsd:anyAttribute namespace="##other" processContents="lax"/> </xsd:complexType> </xsd:schema> <?xml version="1.0" encoding="UTF-8"?> <xsd:schema xmlns:open="http://www.example.com/bad" xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.example.com/bad"> <xsd:attribute name="globAttribute" type="xsd:decimal"/> <xsd:complexType name="OneElementAndAnyAttr"> <xsd:sequence> <xsd:element name="name" type="xsd:string"/> </xsd:sequence> <xsd:anyAttribute processContents="lax"/> </xsd:complexType> </xsd:schema> If I define each schema with a separate context, I get the last part of the URI as the namespace indicator. If I define both with the same context, I get the same indicator as in the schema. This should make it clearer. Here's my code: HelperContext context = SDOUtil.createHelperContext(); HelperContext context2 = SDOUtil.createHelperContext(); context.getXSDHelper().define(new FileInputStream("./Person.xsd"), (new File("./Person.xsd")).toURI().toString()); DataObject person = context.getDataFactory().create("http://www.example.org/Person", "PersonType"); person.setString("Name", "Jim"); person.setString("Age", "30"); context2.getXSDHelper().define(new FileInputStream("./Open.xsd"), (new File("./Open.xsd")).toURI().toString()); Property prop = context2.getTypeHelper().getOpenContentProperty(" http://www.example.com/bad", "globAttribute"); person.set(prop, new BigDecimal(6)); context.getXMLHelper().save((DataObject) person, "http://www.example.org/Person", "Person", System.out); When using context2 as above, I get the following output: <?xml version="1.0" encoding="ASCII"?> <person:Person xmlns:bad="http://www.example.com/bad" xmlns:person="http://www.example.org/Person" bad:globAttribute="6"> <person:Name>Jim</person:Name> <person:Age>30</person:Age> </person:Person> Notice "xmlns:bad" in that output. Now when I remove context2 and use the same context throughout, I get the following output: <?xml version="1.0" encoding="ASCII"?> <person:Person xmlns:open="http://www.example.com/bad" xmlns:person="http://www.example.org/Person" open:globAttribute="6"> <person:Name>Jim</person:Name> <person:Age>30</person:Age> </person:Person> This output has "xmlns:open". I'm wondering, is this the expected behavior? Also, is there a way for me to define this string through other parameters? Thanks, -Chris --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
