Home » Archived » XML Schema Definition (XSD) » Creating complexType with simpleContent
Creating complexType with simpleContent [message #61274] |
Wed, 08 June 2005 13:43  |
Eclipse User |
|
|
|
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 13:49   |
Eclipse User |
|
|
|
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 13:20   |
Eclipse User |
|
|
|
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 13:28   |
Eclipse User |
|
|
|
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 14:00   |
Eclipse User |
|
|
|
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 this should do the trick:<br>
<br>
//anonymousSimpleTypeDefinition.setBaseTypeDefinition(xsdBas eType); <br>
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:
<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(<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"><merks@ca.ibm.com></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
<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:
</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
<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
</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 14:17  |
Eclipse User |
|
|
|
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! 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> </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" <<A =
href=3D"mailto:merks@ca.ibm.com">merks@ca.ibm.com</A>>=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 =20
this should do the =
trick:<BR><BR> =20
=
//anonymousSimpleTypeDefinition.setBaseTypeDefinition(xsdBas eType); <BR>&n=
bsp; &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 13:49  |
Eclipse User |
|
|
|
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 #595552 is a reply to message #61298] |
Thu, 09 June 2005 13:20  |
Eclipse User |
|
|
|
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 13:28  |
Eclipse User |
|
|
|
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 14:00  |
Eclipse User |
|
|
|
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 this should do the trick:<br>
<br>
//anonymousSimpleTypeDefinition.setBaseTypeDefinition(xsdBas eType); <br>
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:
<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(<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"><merks@ca.ibm.com></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
<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:
</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
<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
</pre>
</blockquote>
</blockquote>
<pre wrap=""><!---->
</pre>
</blockquote>
<br>
</body>
</html>
--------------080408000806010200010005--
|
|
|
Re: Creating complexType with simpleContent [message #595576 is a reply to message #61364] |
Thu, 09 June 2005 14:17  |
Eclipse User |
|
|
|
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! 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> </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" <<A =
href=3D"mailto:merks@ca.ibm.com">merks@ca.ibm.com</A>>=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 =20
this should do the =
trick:<BR><BR> =20
=
//anonymousSimpleTypeDefinition.setBaseTypeDefinition(xsdBas eType); <BR>&n=
bsp; &n bsp;=20
=
complexType.setBaseTypeDefinition(xsdBaseType);<BR><BR><BR ></BLOCKQUOTE><=
/BODY></HTML>
------=_NextPart_000_0028_01C56CED.478F26A0--
|
|
|
Goto Forum:
Current Time: Fri May 09 22:31:27 EDT 2025
Powered by FUDForum. Page generated in 0.03987 seconds
|