Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » XML Schema Definition (XSD) » Creating complexType with simpleContent
Creating complexType with simpleContent [message #61274] Wed, 08 June 2005 17:43 Go to next message
Dave Carlson is currently offline Dave CarlsonFriend
Messages: 402
Registered: July 2009
Senior Member
I'm trying to construct a schema via the API, where a complexType extends a
simpleType (maybe indirectly via another complexType with simpleContent). I
can't get the output XSD file to produce <simpleContent> in that
complexType.

For example, a small excerpt from OAGIS 8.0 schema:

<xs:complexType name="Name">
<xs:simpleContent>
<xs:extension base="LingualString"/>
</xs:simpleContent>
</xs:complexType>

<xs:complexType name="LingualString">
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute name="lang" type="xs:language"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>

Reviewing the XSDPrototypicalSchema.java example, simpleContent is produced
only by adding an anonymous simpleType as content. I tried setting the
contentTypeCategory directly, but no affect on the generated schema.

complexType.setContentTypeCategory(XSDContentTypeCategory.SI MPLE_LITERAL);

I always get <xs:complexContent> in both of these types, which is incorrect.
Is this a bug? I am using EMF/XSD 2.1 20050428 build.

Thanks,
Dave Carlson
Re: Creating complexType with simpleContent [message #61298 is a reply to message #61274] Wed, 08 June 2005 17:49 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: merks.ca.ibm.com

Dave,

Yes, you must do it as shown in the XSDPrototypicalSchema example. The
anonymous simple type is just part of the syntax (i.e., it corresponds
to <xs:simpleContent> which has a grammar much like that for
<xs:simpleType>) and doesn't become part of the abstract component model
in the case of simple extension.


Dave Carlson wrote:

>I'm trying to construct a schema via the API, where a complexType extends a
>simpleType (maybe indirectly via another complexType with simpleContent). I
>can't get the output XSD file to produce <simpleContent> in that
>complexType.
>
>For example, a small excerpt from OAGIS 8.0 schema:
>
><xs:complexType name="Name">
><xs:simpleContent>
><xs:extension base="LingualString"/>
></xs:simpleContent>
></xs:complexType>
>
><xs:complexType name="LingualString">
><xs:simpleContent>
><xs:extension base="xs:string">
><xs:attribute name="lang" type="xs:language"/>
></xs:extension>
></xs:simpleContent>
></xs:complexType>
>
>Reviewing the XSDPrototypicalSchema.java example, simpleContent is produced
>only by adding an anonymous simpleType as content. I tried setting the
>contentTypeCategory directly, but no affect on the generated schema.
>
> complexType.setContentTypeCategory(XSDContentTypeCategory.SI MPLE_LITERAL);
>
>I always get <xs:complexContent> in both of these types, which is incorrect.
>Is this a bug? I am using EMF/XSD 2.1 20050428 build.
>
>Thanks,
> Dave Carlson
>
>
>
>
Re: Creating complexType with simpleContent [message #61321 is a reply to message #61298] Thu, 09 June 2005 17:20 Go to previous messageGo to next message
Dave Carlson is currently offline Dave CarlsonFriend
Messages: 402
Registered: July 2009
Senior Member
Hi Ed,

I'm still stuck on this one... as far as I can see, I have exactly the same
code as used in the prototypical example, and I now get the simpleContent,
but the base type is always written as xsd:anyType in the output. In the
debugger, anonymousSimpleTypeDefinition shows its base type set correctly as
"string" with the XSD namespace. But output as:

<xsd:complexType name="LingualString">
<xsd:simpleContent>
<xsd:extension base="xsd:anyType"/>
</xsd:simpleContent>
</xsd:complexType>

Here is the code I used:

XSDSchema xsdSchema = XSDFactory.eINSTANCE.createXSDSchema();
xsdSchema.setSchemaForSchemaQNamePrefix("xsd");
Map qNamePrefixToNamespaceMap =
xsdSchema.getQNamePrefixToNamespaceMap();
qNamePrefixToNamespaceMap.put(xsdSchema.getSchemaForSchemaQN amePrefix(),
XSDConstants.SCHEMA_FOR_SCHEMA_URI_2001);
xsdSchema.setTargetNamespace("http://www.test.com/testsimple");
qNamePrefixToNamespaceMap.put("con", "http://www.test.com/testsimple");

XSDComplexTypeDefinition complexType =
XSDFactory.eINSTANCE.createXSDComplexTypeDefinition();
complexType.setName("LingualString");
complexType.setDerivationMethod(XSDDerivationMethod.EXTENSIO N_LITERAL);

XSDSimpleTypeDefinition xsdBaseType =
xsdSchema.getSchemaForSchema().resolveSimpleTypeDefinition("string ");

XSDSimpleTypeDefinition anonymousSimpleTypeDefinition =
XSDFactory.eINSTANCE.createXSDSimpleTypeDefinition();
anonymousSimpleTypeDefinition.setBaseTypeDefinition(xsdBaseT ype);
complexType.setContent(anonymousSimpleTypeDefinition);

xsdSchema.getContents().add(complexType);

"Ed Merks" <merks@ca.ibm.com> wrote in message
news:d87b2q$lpi$1@news.eclipse.org...
> Dave,
>
> Yes, you must do it as shown in the XSDPrototypicalSchema example. The
> anonymous simple type is just part of the syntax (i.e., it corresponds to
> <xs:simpleContent> which has a grammar much like that for <xs:simpleType>)
> and doesn't become part of the abstract component model in the case of
> simple extension.
>
>
> Dave Carlson wrote:
>
>>I'm trying to construct a schema via the API, where a complexType extends
>>a simpleType (maybe indirectly via another complexType with
>>simpleContent). I can't get the output XSD file to produce
>><simpleContent> in that complexType.
>>
>>For example, a small excerpt from OAGIS 8.0 schema:
>>
>><xs:complexType name="Name">
>><xs:simpleContent>
>><xs:extension base="LingualString"/>
>></xs:simpleContent>
>></xs:complexType>
>>
>><xs:complexType name="LingualString">
>><xs:simpleContent>
>><xs:extension base="xs:string">
>><xs:attribute name="lang" type="xs:language"/>
>></xs:extension>
>></xs:simpleContent>
>></xs:complexType>
>>
>>Reviewing the XSDPrototypicalSchema.java example, simpleContent is
>>produced only by adding an anonymous simpleType as content. I tried
>>setting the contentTypeCategory directly, but no affect on the generated
>>schema.
>>
>>
>> complexType.setContentTypeCategory(XSDContentTypeCategory.SI MPLE_LITERAL);
>>
>>I always get <xs:complexContent> in both of these types, which is
>>incorrect. Is this a bug? I am using EMF/XSD 2.1 20050428 build.
>>
>>Thanks,
>> Dave Carlson
>>
>>
>>
Re: Creating complexType with simpleContent [message #61343 is a reply to message #61298] Thu, 09 June 2005 17:28 Go to previous messageGo to next message
Dave Carlson is currently offline Dave CarlsonFriend
Messages: 402
Registered: July 2009
Senior Member
Hi Ed,

I'm still stuck on this one... as far as I can see I'm using the same code
as the prototypical example, and I now get simpleContent, but the base type
is always written as xsd:anyType in the output. In the debugger
anonymousSimpleTypeDefinition shows its baseTypeDefinition set correctly to
"string" with the XSD namespace. I get this output:

<xsd:complexType name="LingualString">
<xsd:simpleContent>
<xsd:extension base="xsd:anyType"/>
</xsd:simpleContent>
</xsd:complexType>

Here is the code I used:

XSDSchema xsdSchema = XSDFactory.eINSTANCE.createXSDSchema();
xsdSchema.setSchemaForSchemaQNamePrefix("xsd");
Map qNamePrefixToNamespaceMap =
xsdSchema.getQNamePrefixToNamespaceMap();
qNamePrefixToNamespaceMap.put(xsdSchema.getSchemaForSchemaQN amePrefix(),
XSDConstants.SCHEMA_FOR_SCHEMA_URI_2001);
xsdSchema.setTargetNamespace("http://www.test.com/testsimple");
qNamePrefixToNamespaceMap.put("con", "http://www.test.com/testsimple");

XSDComplexTypeDefinition complexType =
XSDFactory.eINSTANCE.createXSDComplexTypeDefinition();
complexType.setName("LingualString");
complexType.setDerivationMethod(XSDDerivationMethod.EXTENSIO N_LITERAL);

XSDSimpleTypeDefinition xsdBaseType =
xsdSchema.getSchemaForSchema().resolveSimpleTypeDefinition("string ");

XSDSimpleTypeDefinition anonymousSimpleTypeDefinition =
XSDFactory.eINSTANCE.createXSDSimpleTypeDefinition();
anonymousSimpleTypeDefinition.setBaseTypeDefinition(xsdBaseT ype);
complexType.setContent(anonymousSimpleTypeDefinition);

xsdSchema.getContents().add(complexType);

"Ed Merks" <merks@ca.ibm.com> wrote in message
news:d87b2q$lpi$1@news.eclipse.org...
> Dave,
>
> Yes, you must do it as shown in the XSDPrototypicalSchema example. The
> anonymous simple type is just part of the syntax (i.e., it corresponds to
> <xs:simpleContent> which has a grammar much like that for <xs:simpleType>)
> and doesn't become part of the abstract component model in the case of
> simple extension.
>
>
> Dave Carlson wrote:
>
>>I'm trying to construct a schema via the API, where a complexType extends
>>a simpleType (maybe indirectly via another complexType with
>>simpleContent). I can't get the output XSD file to produce
>><simpleContent> in that complexType.
>>
>>For example, a small excerpt from OAGIS 8.0 schema:
>>
>><xs:complexType name="Name">
>><xs:simpleContent>
>><xs:extension base="LingualString"/>
>></xs:simpleContent>
>></xs:complexType>
>>
>><xs:complexType name="LingualString">
>><xs:simpleContent>
>><xs:extension base="xs:string">
>><xs:attribute name="lang" type="xs:language"/>
>></xs:extension>
>></xs:simpleContent>
>></xs:complexType>
>>
>>Reviewing the XSDPrototypicalSchema.java example, simpleContent is
>>produced only by adding an anonymous simpleType as content. I tried
>>setting the contentTypeCategory directly, but no affect on the generated
>>schema.
>>
>>
>> complexType.setContentTypeCategory(XSDContentTypeCategory.SI MPLE_LITERAL);
>>
>>I always get <xs:complexContent> in both of these types, which is
>>incorrect. Is this a bug? I am using EMF/XSD 2.1 20050428 build.
>>
>>Thanks,
>> Dave Carlson
>>
>>
>>
Re: Creating complexType with simpleContent [message #61364 is a reply to message #61343] Thu, 09 June 2005 18:00 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: merks.ca.ibm.com

This is a multi-part message in MIME format.
--------------080408000806010200010005
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

Dave,

Changing this should do the trick:

//anonymousSimpleTypeDefinition.setBaseTypeDefinition(xsdBas eType);
complexType.setBaseTypeDefinition(xsdBaseType);


Dave Carlson wrote:

>Hi Ed,
>
>I'm still stuck on this one... as far as I can see I'm using the same code
>as the prototypical example, and I now get simpleContent, but the base type
>is always written as xsd:anyType in the output. In the debugger
>anonymousSimpleTypeDefinition shows its baseTypeDefinition set correctly to
>"string" with the XSD namespace. I get this output:
>
><xsd:complexType name="LingualString">
> <xsd:simpleContent>
> <xsd:extension base="xsd:anyType"/>
> </xsd:simpleContent>
></xsd:complexType>
>
>Here is the code I used:
>
> XSDSchema xsdSchema = XSDFactory.eINSTANCE.createXSDSchema();
> xsdSchema.setSchemaForSchemaQNamePrefix("xsd");
> Map qNamePrefixToNamespaceMap =
>xsdSchema.getQNamePrefixToNamespaceMap();
> qNamePrefixToNamespaceMap.put(xsdSchema.getSchemaForSchemaQN amePrefix(),
>XSDConstants.SCHEMA_FOR_SCHEMA_URI_2001);
> xsdSchema.setTargetNamespace("http://www.test.com/testsimple");
> qNamePrefixToNamespaceMap.put("con", "http://www.test.com/testsimple");
>
> XSDComplexTypeDefinition complexType =
>XSDFactory.eINSTANCE.createXSDComplexTypeDefinition();
> complexType.setName("LingualString");
> complexType.setDerivationMethod(XSDDerivationMethod.EXTENSIO N_LITERAL);
>
> XSDSimpleTypeDefinition xsdBaseType =
>xsdSchema.getSchemaForSchema().resolveSimpleTypeDefinition( "string");
>
> XSDSimpleTypeDefinition anonymousSimpleTypeDefinition =
>XSDFactory.eINSTANCE.createXSDSimpleTypeDefinition();
> anonymousSimpleTypeDefinition.setBaseTypeDefinition(xsdBaseT ype);
> complexType.setContent(anonymousSimpleTypeDefinition);
>
> xsdSchema.getContents().add(complexType);
>
>"Ed Merks" <merks@ca.ibm.com> wrote in message
>news:d87b2q$lpi$1@news.eclipse.org...
>
>
>>Dave,
>>
>>Yes, you must do it as shown in the XSDPrototypicalSchema example. The
>>anonymous simple type is just part of the syntax (i.e., it corresponds to
>><xs:simpleContent> which has a grammar much like that for <xs:simpleType>)
>>and doesn't become part of the abstract component model in the case of
>>simple extension.
>>
>>
>>Dave Carlson wrote:
>>
>>
>>
>>>I'm trying to construct a schema via the API, where a complexType extends
>>>a simpleType (maybe indirectly via another complexType with
>>>simpleContent). I can't get the output XSD file to produce
>>><simpleContent> in that complexType.
>>>
>>>For example, a small excerpt from OAGIS 8.0 schema:
>>>
>>><xs:complexType name="Name">
>>><xs:simpleContent>
>>><xs:extension base="LingualString"/>
>>></xs:simpleContent>
>>></xs:complexType>
>>>
>>><xs:complexType name="LingualString">
>>><xs:simpleContent>
>>><xs:extension base="xs:string">
>>><xs:attribute name="lang" type="xs:language"/>
>>></xs:extension>
>>></xs:simpleContent>
>>></xs:complexType>
>>>
>>>Reviewing the XSDPrototypicalSchema.java example, simpleContent is
>>>produced only by adding an anonymous simpleType as content. I tried
>>>setting the contentTypeCategory directly, but no affect on the generated
>>>schema.
>>>
>>>
>>> complexType.setContentTypeCategory(XSDContentTypeCategory.SI MPLE_LITERAL);
>>>
>>>I always get <xs:complexContent> in both of these types, which is
>>>incorrect. Is this a bug? I am using EMF/XSD 2.1 20050428 build.
>>>
>>>Thanks,
>>> Dave Carlson
>>>
>>>
>>>
>>>
>>>
>
>
>
>


--------------080408000806010200010005
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Dave,<br>
<br>
Changing&nbsp; this should do the trick:<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;
//anonymousSimpleTypeDefinition.setBaseTypeDefinition(xsdBas eType); <br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; complexType.setBaseTypeDefinition(xsdBaseType);<br>
<br>
<br>
Dave Carlson wrote:
<blockquote cite="midd89u8a$ljb$1@news.eclipse.org" type="cite">
<pre wrap="">Hi Ed,

I'm still stuck on this one... as far as I can see I'm using the same code
as the prototypical example, and I now get simpleContent, but the base type
is always written as xsd:anyType in the output. In the debugger
anonymousSimpleTypeDefinition shows its baseTypeDefinition set correctly to
"string" with the XSD namespace. I get this output:

&lt;xsd:complexType name="LingualString"&gt;
&lt;xsd:simpleContent&gt;
&lt;xsd:extension base="xsd:anyType"/&gt;
&lt;/xsd:simpleContent&gt;
&lt;/xsd:complexType&gt;

Here is the code I used:

XSDSchema xsdSchema = XSDFactory.eINSTANCE.createXSDSchema();
xsdSchema.setSchemaForSchemaQNamePrefix("xsd");
Map qNamePrefixToNamespaceMap =
xsdSchema.getQNamePrefixToNamespaceMap();
qNamePrefixToNamespaceMap.put(xsdSchema.getSchemaForSchemaQN amePrefix(),
XSDConstants.SCHEMA_FOR_SCHEMA_URI_2001);
xsdSchema.setTargetNamespace(<a class="moz-txt-link-rfc2396E" href="http://www.test.com/testsimple">"http://www.test.com/testsimple"</a>);
qNamePrefixToNamespaceMap.put("con", <a class="moz-txt-link-rfc2396E" href="http://www.test.com/testsimple">"http://www.test.com/testsimple"</a>);

XSDComplexTypeDefinition complexType =
XSDFactory.eINSTANCE.createXSDComplexTypeDefinition();
complexType.setName("LingualString");
complexType.setDerivationMethod(XSDDerivationMethod.EXTENSIO N_LITERAL);

XSDSimpleTypeDefinition xsdBaseType =
xsdSchema.getSchemaForSchema().resolveSimpleTypeDefinition("string ");

XSDSimpleTypeDefinition anonymousSimpleTypeDefinition =
XSDFactory.eINSTANCE.createXSDSimpleTypeDefinition();
anonymousSimpleTypeDefinition.setBaseTypeDefinition(xsdBaseT ype);
complexType.setContent(anonymousSimpleTypeDefinition);

xsdSchema.getContents().add(complexType);

"Ed Merks" <a class="moz-txt-link-rfc2396E" href="mailto:merks@ca.ibm.com">&lt;merks@ca.ibm.com&gt;</a> wrote in message
<a class="moz-txt-link-freetext" href="news:d87b2q$lpi$1@news.eclipse.org">news:d87b2q$lpi$1@news.eclipse.org</a>...
</pre>
<blockquote type="cite">
<pre wrap="">Dave,

Yes, you must do it as shown in the XSDPrototypicalSchema example. The
anonymous simple type is just part of the syntax (i.e., it corresponds to
&lt;xs:simpleContent&gt; which has a grammar much like that for &lt;xs:simpleType&gt;)
and doesn't become part of the abstract component model in the case of
simple extension.


Dave Carlson wrote:

</pre>
<blockquote type="cite">
<pre wrap="">I'm trying to construct a schema via the API, where a complexType extends
a simpleType (maybe indirectly via another complexType with
simpleContent). I can't get the output XSD file to produce
&lt;simpleContent&gt; in that complexType.

For example, a small excerpt from OAGIS 8.0 schema:

&lt;xs:complexType name="Name"&gt;
&lt;xs:simpleContent&gt;
&lt;xs:extension base="LingualString"/&gt;
&lt;/xs:simpleContent&gt;
&lt;/xs:complexType&gt;

&lt;xs:complexType name="LingualString"&gt;
&lt;xs:simpleContent&gt;
&lt;xs:extension base="xs:string"&gt;
&lt;xs:attribute name="lang" type="xs:language"/&gt;
&lt;/xs:extension&gt;
&lt;/xs:simpleContent&gt;
&lt;/xs:complexType&gt;

Reviewing the XSDPrototypicalSchema.java example, simpleContent is
produced only by adding an anonymous simpleType as content. I tried
setting the contentTypeCategory directly, but no affect on the generated
schema.


complexType.setContentTypeCategory(XSDContentTypeCategory.SI MPLE_LITERAL);

I always get &lt;xs:complexContent&gt; in both of these types, which is
incorrect. Is this a bug? I am using EMF/XSD 2.1 20050428 build.

Thanks,
Dave Carlson



</pre>
</blockquote>
</blockquote>
<pre wrap=""><!---->

</pre>
</blockquote>
<br>
</body>
</html>

--------------080408000806010200010005--
Re: Creating complexType with simpleContent [message #61388 is a reply to message #61364] Thu, 09 June 2005 18:17 Go to previous message
Dave Carlson is currently offline Dave CarlsonFriend
Messages: 402
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.

------=_NextPart_000_0028_01C56CED.478F26A0
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

Thanks Ed! It was not intuitive to create an anonymous type with no =
content and no base type, and use it it "trick" the compexType into =
interpreting its simple base type as simpleContent...

Dave
"Ed Merks" <merks@ca.ibm.com> wrote in message =
news:d8a03k$nr0$1@news.eclipse.org...
Dave,

Changing this should do the trick:

=
//anonymousSimpleTypeDefinition.setBaseTypeDefinition(xsdBas eType);
complexType.setBaseTypeDefinition(xsdBaseType);



------=_NextPart_000_0028_01C56CED.478F26A0
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type =
content=3Dtext/html;charset=3DISO-8859-1>
<META content=3D"MSHTML 6.00.2900.2627" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY text=3D#000000 bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2>Thanks Ed!&nbsp; It was not intuitive =
to create an=20
anonymous type with no content and no base type, and use it it "trick" =
the=20
compexType into interpreting its simple base type as=20
simpleContent...</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Dave</FONT></DIV>
<BLOCKQUOTE=20
style=3D"PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; =
BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
<DIV>"Ed Merks" &lt;<A =
href=3D"mailto:merks@ca.ibm.com">merks@ca.ibm.com</A>&gt;=20
wrote in message <A=20
=
href=3D"news:d8a03k$nr0$1@news.eclipse.org">news:d8a03k$nr0$1@news.eclips=
e.org</A>...</DIV>Dave,<BR><BR>Changing&nbsp;=20
this should do the =
trick:<BR><BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;=20
=
//anonymousSimpleTypeDefinition.setBaseTypeDefinition(xsdBas eType); <BR>&n=
bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n bsp;=20
=
complexType.setBaseTypeDefinition(xsdBaseType);<BR><BR><BR ></BLOCKQUOTE><=
/BODY></HTML>

------=_NextPart_000_0028_01C56CED.478F26A0--
Re: Creating complexType with simpleContent [message #595544 is a reply to message #61274] Wed, 08 June 2005 17:49 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33113
Registered: July 2009
Senior Member
Dave,

Yes, you must do it as shown in the XSDPrototypicalSchema example. The
anonymous simple type is just part of the syntax (i.e., it corresponds
to <xs:simpleContent> which has a grammar much like that for
<xs:simpleType>) and doesn't become part of the abstract component model
in the case of simple extension.


Dave Carlson wrote:

>I'm trying to construct a schema via the API, where a complexType extends a
>simpleType (maybe indirectly via another complexType with simpleContent). I
>can't get the output XSD file to produce <simpleContent> in that
>complexType.
>
>For example, a small excerpt from OAGIS 8.0 schema:
>
><xs:complexType name="Name">
><xs:simpleContent>
><xs:extension base="LingualString"/>
></xs:simpleContent>
></xs:complexType>
>
><xs:complexType name="LingualString">
><xs:simpleContent>
><xs:extension base="xs:string">
><xs:attribute name="lang" type="xs:language"/>
></xs:extension>
></xs:simpleContent>
></xs:complexType>
>
>Reviewing the XSDPrototypicalSchema.java example, simpleContent is produced
>only by adding an anonymous simpleType as content. I tried setting the
>contentTypeCategory directly, but no affect on the generated schema.
>
> complexType.setContentTypeCategory(XSDContentTypeCategory.SI MPLE_LITERAL);
>
>I always get <xs:complexContent> in both of these types, which is incorrect.
>Is this a bug? I am using EMF/XSD 2.1 20050428 build.
>
>Thanks,
> Dave Carlson
>
>
>
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Creating complexType with simpleContent [message #595552 is a reply to message #61298] Thu, 09 June 2005 17:20 Go to previous message
Dave Carlson is currently offline Dave CarlsonFriend
Messages: 402
Registered: July 2009
Senior Member
Hi Ed,

I'm still stuck on this one... as far as I can see, I have exactly the same
code as used in the prototypical example, and I now get the simpleContent,
but the base type is always written as xsd:anyType in the output. In the
debugger, anonymousSimpleTypeDefinition shows its base type set correctly as
"string" with the XSD namespace. But output as:

<xsd:complexType name="LingualString">
<xsd:simpleContent>
<xsd:extension base="xsd:anyType"/>
</xsd:simpleContent>
</xsd:complexType>

Here is the code I used:

XSDSchema xsdSchema = XSDFactory.eINSTANCE.createXSDSchema();
xsdSchema.setSchemaForSchemaQNamePrefix("xsd");
Map qNamePrefixToNamespaceMap =
xsdSchema.getQNamePrefixToNamespaceMap();
qNamePrefixToNamespaceMap.put(xsdSchema.getSchemaForSchemaQN amePrefix(),
XSDConstants.SCHEMA_FOR_SCHEMA_URI_2001);
xsdSchema.setTargetNamespace("http://www.test.com/testsimple");
qNamePrefixToNamespaceMap.put("con", "http://www.test.com/testsimple");

XSDComplexTypeDefinition complexType =
XSDFactory.eINSTANCE.createXSDComplexTypeDefinition();
complexType.setName("LingualString");
complexType.setDerivationMethod(XSDDerivationMethod.EXTENSIO N_LITERAL);

XSDSimpleTypeDefinition xsdBaseType =
xsdSchema.getSchemaForSchema().resolveSimpleTypeDefinition("string ");

XSDSimpleTypeDefinition anonymousSimpleTypeDefinition =
XSDFactory.eINSTANCE.createXSDSimpleTypeDefinition();
anonymousSimpleTypeDefinition.setBaseTypeDefinition(xsdBaseT ype);
complexType.setContent(anonymousSimpleTypeDefinition);

xsdSchema.getContents().add(complexType);

"Ed Merks" <merks@ca.ibm.com> wrote in message
news:d87b2q$lpi$1@news.eclipse.org...
> Dave,
>
> Yes, you must do it as shown in the XSDPrototypicalSchema example. The
> anonymous simple type is just part of the syntax (i.e., it corresponds to
> <xs:simpleContent> which has a grammar much like that for <xs:simpleType>)
> and doesn't become part of the abstract component model in the case of
> simple extension.
>
>
> Dave Carlson wrote:
>
>>I'm trying to construct a schema via the API, where a complexType extends
>>a simpleType (maybe indirectly via another complexType with
>>simpleContent). I can't get the output XSD file to produce
>><simpleContent> in that complexType.
>>
>>For example, a small excerpt from OAGIS 8.0 schema:
>>
>><xs:complexType name="Name">
>><xs:simpleContent>
>><xs:extension base="LingualString"/>
>></xs:simpleContent>
>></xs:complexType>
>>
>><xs:complexType name="LingualString">
>><xs:simpleContent>
>><xs:extension base="xs:string">
>><xs:attribute name="lang" type="xs:language"/>
>></xs:extension>
>></xs:simpleContent>
>></xs:complexType>
>>
>>Reviewing the XSDPrototypicalSchema.java example, simpleContent is
>>produced only by adding an anonymous simpleType as content. I tried
>>setting the contentTypeCategory directly, but no affect on the generated
>>schema.
>>
>>
>> complexType.setContentTypeCategory(XSDContentTypeCategory.SI MPLE_LITERAL);
>>
>>I always get <xs:complexContent> in both of these types, which is
>>incorrect. Is this a bug? I am using EMF/XSD 2.1 20050428 build.
>>
>>Thanks,
>> Dave Carlson
>>
>>
>>
Re: Creating complexType with simpleContent [message #595557 is a reply to message #61298] Thu, 09 June 2005 17:28 Go to previous message
Dave Carlson is currently offline Dave CarlsonFriend
Messages: 402
Registered: July 2009
Senior Member
Hi Ed,

I'm still stuck on this one... as far as I can see I'm using the same code
as the prototypical example, and I now get simpleContent, but the base type
is always written as xsd:anyType in the output. In the debugger
anonymousSimpleTypeDefinition shows its baseTypeDefinition set correctly to
"string" with the XSD namespace. I get this output:

<xsd:complexType name="LingualString">
<xsd:simpleContent>
<xsd:extension base="xsd:anyType"/>
</xsd:simpleContent>
</xsd:complexType>

Here is the code I used:

XSDSchema xsdSchema = XSDFactory.eINSTANCE.createXSDSchema();
xsdSchema.setSchemaForSchemaQNamePrefix("xsd");
Map qNamePrefixToNamespaceMap =
xsdSchema.getQNamePrefixToNamespaceMap();
qNamePrefixToNamespaceMap.put(xsdSchema.getSchemaForSchemaQN amePrefix(),
XSDConstants.SCHEMA_FOR_SCHEMA_URI_2001);
xsdSchema.setTargetNamespace("http://www.test.com/testsimple");
qNamePrefixToNamespaceMap.put("con", "http://www.test.com/testsimple");

XSDComplexTypeDefinition complexType =
XSDFactory.eINSTANCE.createXSDComplexTypeDefinition();
complexType.setName("LingualString");
complexType.setDerivationMethod(XSDDerivationMethod.EXTENSIO N_LITERAL);

XSDSimpleTypeDefinition xsdBaseType =
xsdSchema.getSchemaForSchema().resolveSimpleTypeDefinition("string ");

XSDSimpleTypeDefinition anonymousSimpleTypeDefinition =
XSDFactory.eINSTANCE.createXSDSimpleTypeDefinition();
anonymousSimpleTypeDefinition.setBaseTypeDefinition(xsdBaseT ype);
complexType.setContent(anonymousSimpleTypeDefinition);

xsdSchema.getContents().add(complexType);

"Ed Merks" <merks@ca.ibm.com> wrote in message
news:d87b2q$lpi$1@news.eclipse.org...
> Dave,
>
> Yes, you must do it as shown in the XSDPrototypicalSchema example. The
> anonymous simple type is just part of the syntax (i.e., it corresponds to
> <xs:simpleContent> which has a grammar much like that for <xs:simpleType>)
> and doesn't become part of the abstract component model in the case of
> simple extension.
>
>
> Dave Carlson wrote:
>
>>I'm trying to construct a schema via the API, where a complexType extends
>>a simpleType (maybe indirectly via another complexType with
>>simpleContent). I can't get the output XSD file to produce
>><simpleContent> in that complexType.
>>
>>For example, a small excerpt from OAGIS 8.0 schema:
>>
>><xs:complexType name="Name">
>><xs:simpleContent>
>><xs:extension base="LingualString"/>
>></xs:simpleContent>
>></xs:complexType>
>>
>><xs:complexType name="LingualString">
>><xs:simpleContent>
>><xs:extension base="xs:string">
>><xs:attribute name="lang" type="xs:language"/>
>></xs:extension>
>></xs:simpleContent>
>></xs:complexType>
>>
>>Reviewing the XSDPrototypicalSchema.java example, simpleContent is
>>produced only by adding an anonymous simpleType as content. I tried
>>setting the contentTypeCategory directly, but no affect on the generated
>>schema.
>>
>>
>> complexType.setContentTypeCategory(XSDContentTypeCategory.SI MPLE_LITERAL);
>>
>>I always get <xs:complexContent> in both of these types, which is
>>incorrect. Is this a bug? I am using EMF/XSD 2.1 20050428 build.
>>
>>Thanks,
>> Dave Carlson
>>
>>
>>
Re: Creating complexType with simpleContent [message #595568 is a reply to message #61343] Thu, 09 June 2005 18:00 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33113
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.
--------------080408000806010200010005
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

Dave,

Changing this should do the trick:

//anonymousSimpleTypeDefinition.setBaseTypeDefinition(xsdBas eType);
complexType.setBaseTypeDefinition(xsdBaseType);


Dave Carlson wrote:

>Hi Ed,
>
>I'm still stuck on this one... as far as I can see I'm using the same code
>as the prototypical example, and I now get simpleContent, but the base type
>is always written as xsd:anyType in the output. In the debugger
>anonymousSimpleTypeDefinition shows its baseTypeDefinition set correctly to
>"string" with the XSD namespace. I get this output:
>
><xsd:complexType name="LingualString">
> <xsd:simpleContent>
> <xsd:extension base="xsd:anyType"/>
> </xsd:simpleContent>
></xsd:complexType>
>
>Here is the code I used:
>
> XSDSchema xsdSchema = XSDFactory.eINSTANCE.createXSDSchema();
> xsdSchema.setSchemaForSchemaQNamePrefix("xsd");
> Map qNamePrefixToNamespaceMap =
>xsdSchema.getQNamePrefixToNamespaceMap();
> qNamePrefixToNamespaceMap.put(xsdSchema.getSchemaForSchemaQN amePrefix(),
>XSDConstants.SCHEMA_FOR_SCHEMA_URI_2001);
> xsdSchema.setTargetNamespace("http://www.test.com/testsimple");
> qNamePrefixToNamespaceMap.put("con", "http://www.test.com/testsimple");
>
> XSDComplexTypeDefinition complexType =
>XSDFactory.eINSTANCE.createXSDComplexTypeDefinition();
> complexType.setName("LingualString");
> complexType.setDerivationMethod(XSDDerivationMethod.EXTENSIO N_LITERAL);
>
> XSDSimpleTypeDefinition xsdBaseType =
>xsdSchema.getSchemaForSchema().resolveSimpleTypeDefinition( "string");
>
> XSDSimpleTypeDefinition anonymousSimpleTypeDefinition =
>XSDFactory.eINSTANCE.createXSDSimpleTypeDefinition();
> anonymousSimpleTypeDefinition.setBaseTypeDefinition(xsdBaseT ype);
> complexType.setContent(anonymousSimpleTypeDefinition);
>
> xsdSchema.getContents().add(complexType);
>
>"Ed Merks" <merks@ca.ibm.com> wrote in message
>news:d87b2q$lpi$1@news.eclipse.org...
>
>
>>Dave,
>>
>>Yes, you must do it as shown in the XSDPrototypicalSchema example. The
>>anonymous simple type is just part of the syntax (i.e., it corresponds to
>><xs:simpleContent> which has a grammar much like that for <xs:simpleType>)
>>and doesn't become part of the abstract component model in the case of
>>simple extension.
>>
>>
>>Dave Carlson wrote:
>>
>>
>>
>>>I'm trying to construct a schema via the API, where a complexType extends
>>>a simpleType (maybe indirectly via another complexType with
>>>simpleContent). I can't get the output XSD file to produce
>>><simpleContent> in that complexType.
>>>
>>>For example, a small excerpt from OAGIS 8.0 schema:
>>>
>>><xs:complexType name="Name">
>>><xs:simpleContent>
>>><xs:extension base="LingualString"/>
>>></xs:simpleContent>
>>></xs:complexType>
>>>
>>><xs:complexType name="LingualString">
>>><xs:simpleContent>
>>><xs:extension base="xs:string">
>>><xs:attribute name="lang" type="xs:language"/>
>>></xs:extension>
>>></xs:simpleContent>
>>></xs:complexType>
>>>
>>>Reviewing the XSDPrototypicalSchema.java example, simpleContent is
>>>produced only by adding an anonymous simpleType as content. I tried
>>>setting the contentTypeCategory directly, but no affect on the generated
>>>schema.
>>>
>>>
>>> complexType.setContentTypeCategory(XSDContentTypeCategory.SI MPLE_LITERAL);
>>>
>>>I always get <xs:complexContent> in both of these types, which is
>>>incorrect. Is this a bug? I am using EMF/XSD 2.1 20050428 build.
>>>
>>>Thanks,
>>> Dave Carlson
>>>
>>>
>>>
>>>
>>>
>
>
>
>


--------------080408000806010200010005
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Dave,<br>
<br>
Changing&nbsp; this should do the trick:<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;
//anonymousSimpleTypeDefinition.setBaseTypeDefinition(xsdBas eType); <br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; complexType.setBaseTypeDefinition(xsdBaseType);<br>
<br>
<br>
Dave Carlson wrote:
<blockquote cite="midd89u8a$ljb$1@news.eclipse.org" type="cite">
<pre wrap="">Hi Ed,

I'm still stuck on this one... as far as I can see I'm using the same code
as the prototypical example, and I now get simpleContent, but the base type
is always written as xsd:anyType in the output. In the debugger
anonymousSimpleTypeDefinition shows its baseTypeDefinition set correctly to
"string" with the XSD namespace. I get this output:

&lt;xsd:complexType name="LingualString"&gt;
&lt;xsd:simpleContent&gt;
&lt;xsd:extension base="xsd:anyType"/&gt;
&lt;/xsd:simpleContent&gt;
&lt;/xsd:complexType&gt;

Here is the code I used:

XSDSchema xsdSchema = XSDFactory.eINSTANCE.createXSDSchema();
xsdSchema.setSchemaForSchemaQNamePrefix("xsd");
Map qNamePrefixToNamespaceMap =
xsdSchema.getQNamePrefixToNamespaceMap();
qNamePrefixToNamespaceMap.put(xsdSchema.getSchemaForSchemaQN amePrefix(),
XSDConstants.SCHEMA_FOR_SCHEMA_URI_2001);
xsdSchema.setTargetNamespace(<a class="moz-txt-link-rfc2396E" href="http://www.test.com/testsimple">"http://www.test.com/testsimple"</a>);
qNamePrefixToNamespaceMap.put("con", <a class="moz-txt-link-rfc2396E" href="http://www.test.com/testsimple">"http://www.test.com/testsimple"</a>);

XSDComplexTypeDefinition complexType =
XSDFactory.eINSTANCE.createXSDComplexTypeDefinition();
complexType.setName("LingualString");
complexType.setDerivationMethod(XSDDerivationMethod.EXTENSIO N_LITERAL);

XSDSimpleTypeDefinition xsdBaseType =
xsdSchema.getSchemaForSchema().resolveSimpleTypeDefinition("string ");

XSDSimpleTypeDefinition anonymousSimpleTypeDefinition =
XSDFactory.eINSTANCE.createXSDSimpleTypeDefinition();
anonymousSimpleTypeDefinition.setBaseTypeDefinition(xsdBaseT ype);
complexType.setContent(anonymousSimpleTypeDefinition);

xsdSchema.getContents().add(complexType);

"Ed Merks" <a class="moz-txt-link-rfc2396E" href="mailto:merks@ca.ibm.com">&lt;merks@ca.ibm.com&gt;</a> wrote in message
<a class="moz-txt-link-freetext" href="news:d87b2q$lpi$1@news.eclipse.org">news:d87b2q$lpi$1@news.eclipse.org</a>...
</pre>
<blockquote type="cite">
<pre wrap="">Dave,

Yes, you must do it as shown in the XSDPrototypicalSchema example. The
anonymous simple type is just part of the syntax (i.e., it corresponds to
&lt;xs:simpleContent&gt; which has a grammar much like that for &lt;xs:simpleType&gt;)
and doesn't become part of the abstract component model in the case of
simple extension.


Dave Carlson wrote:

</pre>
<blockquote type="cite">
<pre wrap="">I'm trying to construct a schema via the API, where a complexType extends
a simpleType (maybe indirectly via another complexType with
simpleContent). I can't get the output XSD file to produce
&lt;simpleContent&gt; in that complexType.

For example, a small excerpt from OAGIS 8.0 schema:

&lt;xs:complexType name="Name"&gt;
&lt;xs:simpleContent&gt;
&lt;xs:extension base="LingualString"/&gt;
&lt;/xs:simpleContent&gt;
&lt;/xs:complexType&gt;

&lt;xs:complexType name="LingualString"&gt;
&lt;xs:simpleContent&gt;
&lt;xs:extension base="xs:string"&gt;
&lt;xs:attribute name="lang" type="xs:language"/&gt;
&lt;/xs:extension&gt;
&lt;/xs:simpleContent&gt;
&lt;/xs:complexType&gt;

Reviewing the XSDPrototypicalSchema.java example, simpleContent is
produced only by adding an anonymous simpleType as content. I tried
setting the contentTypeCategory directly, but no affect on the generated
schema.


complexType.setContentTypeCategory(XSDContentTypeCategory.SI MPLE_LITERAL);

I always get &lt;xs:complexContent&gt; in both of these types, which is
incorrect. Is this a bug? I am using EMF/XSD 2.1 20050428 build.

Thanks,
Dave Carlson



</pre>
</blockquote>
</blockquote>
<pre wrap=""><!---->

</pre>
</blockquote>
<br>
</body>
</html>

--------------080408000806010200010005--


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Creating complexType with simpleContent [message #595576 is a reply to message #61364] Thu, 09 June 2005 18:17 Go to previous message
Dave Carlson is currently offline Dave CarlsonFriend
Messages: 402
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.

------=_NextPart_000_0028_01C56CED.478F26A0
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

Thanks Ed! It was not intuitive to create an anonymous type with no =
content and no base type, and use it it "trick" the compexType into =
interpreting its simple base type as simpleContent...

Dave
"Ed Merks" <merks@ca.ibm.com> wrote in message =
news:d8a03k$nr0$1@news.eclipse.org...
Dave,

Changing this should do the trick:

=
//anonymousSimpleTypeDefinition.setBaseTypeDefinition(xsdBas eType);
complexType.setBaseTypeDefinition(xsdBaseType);



------=_NextPart_000_0028_01C56CED.478F26A0
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type =
content=3Dtext/html;charset=3DISO-8859-1>
<META content=3D"MSHTML 6.00.2900.2627" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY text=3D#000000 bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2>Thanks Ed!&nbsp; It was not intuitive =
to create an=20
anonymous type with no content and no base type, and use it it "trick" =
the=20
compexType into interpreting its simple base type as=20
simpleContent...</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Dave</FONT></DIV>
<BLOCKQUOTE=20
style=3D"PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; =
BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
<DIV>"Ed Merks" &lt;<A =
href=3D"mailto:merks@ca.ibm.com">merks@ca.ibm.com</A>&gt;=20
wrote in message <A=20
=
href=3D"news:d8a03k$nr0$1@news.eclipse.org">news:d8a03k$nr0$1@news.eclips=
e.org</A>...</DIV>Dave,<BR><BR>Changing&nbsp;=20
this should do the =
trick:<BR><BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;=20
=
//anonymousSimpleTypeDefinition.setBaseTypeDefinition(xsdBas eType); <BR>&n=
bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n bsp;=20
=
complexType.setBaseTypeDefinition(xsdBaseType);<BR><BR><BR ></BLOCKQUOTE><=
/BODY></HTML>

------=_NextPart_000_0028_01C56CED.478F26A0--
Previous Topic:Creating complexType with simpleContent
Next Topic:How to get elements from included schema?
Goto Forum:
  


Current Time: Fri Mar 29 06:04:18 GMT 2024

Powered by FUDForum. Page generated in 0.26756 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top