You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@tuscany.apache.org by Chris Mildebrandt <tu...@plasticfrog.info> on 2007/05/30 00:01:19 UTC

Issues with namespace indicators

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: tuscany-user-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-user-help@ws.apache.org


Re: Issues with namespace indicators

Posted by Chris Mildebrandt <ch...@plasticfrog.info>.
Hi Kelvin,

Thanks for the reply. We were curious about the inconsistency and
wanted to know if this was the expected behavior. Programmatically,
there's no issue of course. One of the groups I work with has a long
string at the end of the namespace (26 characters) that's being used
as the prefix. They are concerned about the readability of the
resulting XML. They are also concerned about the lack of control of
the metadata. So, not a huge priority since nothing is
programmatically broken on our side, but it's an inconvenience.

-Chris

On 5/30/07, kelvin goodson <ke...@gmail.com> wrote:
> 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 <tu...@plasticfrog.info> 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: tuscany-user-unsubscribe@ws.apache.org
> > For additional commands, e-mail: tuscany-user-help@ws.apache.org
> >
> >
>

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


Re: Issues with namespace indicators

Posted by kelvin goodson <ke...@gmail.com>.
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 <tu...@plasticfrog.info> 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: tuscany-user-unsubscribe@ws.apache.org
> For additional commands, e-mail: tuscany-user-help@ws.apache.org
>
>