Problem with transferring a type definition between two schemas [message #41498] |
Fri, 16 April 2004 07:11  |
Eclipse User |
|
|
|
Hi!
My problem is the following:
I have one larger XSD Schema looking like the following:
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" >
<xs:element name="Name" type="MyComplexType" />
<xs:complexType name="MyComplexType">
<xs:sequence minOccurs="1" maxOccurs="1">
<xs:element name="vorname">
<xs:simpleType >
<xs:restriction base="xs:string">
<xs:minLength value="4"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="nachname" type="xs:string" />
</xs:sequence>
<xs:attribute name="Geburtstag" type="xs:date" />
</xs:complexType>
</xs:schema>
and i want to transform it into something like this:
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" >
<xs:element name="Name" type="MyComplexType" />
<xs:complexType name="MyComplexType">
<xs:sequence minOccurs="1" maxOccurs="1">
<xs:element name="vorname">
<xs:simpleType >
<xs:restriction base="xs:string">
<xs:minLength value="4"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="nachname" type="xs:string" />
</xs:sequence>
<xs:attribute name="Geburtstag" type="xs:date" />
</xs:complexType>
<xs:element name="NameTest">
<xs:simpleType >
<xs:restriction base="xs:string">
<xs:minLength value="4"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
</xs:schema>
this would enable me to create XML instance files with NameTest as root
element.
An now the big question:
Lets asume i have the XSDSimpleTypeDefiniton of the anonymous type
inside the embeded "vorname" element. How can a transfer this to an
newly created XSDELementDeclaration?
I tried the following code:
XSDSimpleTypeDefinition std = getSimpleTypeFromOldSchema();
XSDElementDeclaration elemDecl =
xsdFactory.createXSDElementDeclaration();
elemDecl.setName("NameTest");
newSchema.getContents().add(elemDecl);
elemDecl.setTypeDefinition(std);
this produces an element declaration in the new schema that looks like this:
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:element name="test1" type="vorname_._type"/>
</xsd:schema>
So what can i do to achieve what i want to have?
thanks for your answers.
greets Joachim Lusiardi
|
|
|
|
Re: Problem with transferring a type definition between two schemas [message #41552 is a reply to message #41528] |
Fri, 16 April 2004 07:55  |
Eclipse User |
|
|
|
Hi,
Thanks for your quick answer. Your code works perfectly. You saved me a
lot of time.
greets
Joachim Lusiardi
Ed Merks wrote:
> Joachim,
>
> For this particular scenario, the following should work:
>
> elemDecl.setAnonymousTypeDefinition((XSDSimpleTypeDefinition )std.cloneConcreteComponent(true,
> false));
>
>
> Joachim Lusiardi wrote:
>
>> Hi!
>> My problem is the following:
>> I have one larger XSD Schema looking like the following:
>>
>> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" >
>> <xs:element name="Name" type="MyComplexType" />
>>
>> <xs:complexType name="MyComplexType">
>> <xs:sequence minOccurs="1" maxOccurs="1">
>> <xs:element name="vorname">
>> <xs:simpleType >
>> <xs:restriction base="xs:string">
>> <xs:minLength value="4"/>
>> </xs:restriction>
>> </xs:simpleType>
>> </xs:element>
>> <xs:element name="nachname" type="xs:string" />
>> </xs:sequence>
>> <xs:attribute name="Geburtstag" type="xs:date" />
>> </xs:complexType>
>>
>> </xs:schema>
>>
>> and i want to transform it into something like this:
>>
>> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" >
>> <xs:element name="Name" type="MyComplexType" />
>>
>> <xs:complexType name="MyComplexType">
>> <xs:sequence minOccurs="1" maxOccurs="1">
>> <xs:element name="vorname">
>> <xs:simpleType >
>> <xs:restriction base="xs:string">
>> <xs:minLength value="4"/>
>> </xs:restriction>
>> </xs:simpleType>
>> </xs:element>
>> <xs:element name="nachname" type="xs:string" />
>> </xs:sequence>
>> <xs:attribute name="Geburtstag" type="xs:date" />
>> </xs:complexType>
>>
>> <xs:element name="NameTest">
>> <xs:simpleType >
>> <xs:restriction base="xs:string">
>> <xs:minLength value="4"/>
>> </xs:restriction>
>> </xs:simpleType>
>> </xs:element>
>> </xs:schema>
>>
>> this would enable me to create XML instance files with NameTest as root
>> element.
>>
>> An now the big question:
>> Lets asume i have the XSDSimpleTypeDefiniton of the anonymous type
>> inside the embeded "vorname" element. How can a transfer this to an
>> newly created XSDELementDeclaration?
>>
>> I tried the following code:
>>
>> XSDSimpleTypeDefinition std = getSimpleTypeFromOldSchema();
>> XSDElementDeclaration elemDecl =
>> xsdFactory.createXSDElementDeclaration();
>> elemDecl.setName("NameTest");
>> newSchema.getContents().add(elemDecl);
>> elemDecl.setTypeDefinition(std);
>>
>> this produces an element declaration in the new schema that looks like
>> this:
>>
>> <?xml version="1.0" encoding="UTF-8"?>
>> <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
>> <xsd:element name="test1" type="vorname_._type"/>
>> </xsd:schema>
>>
>> So what can i do to achieve what i want to have?
>>
>> thanks for your answers.
>> greets Joachim Lusiardi
>>
|
|
|
Re: Problem with transferring a type definition between two schemas [message #585662 is a reply to message #41498] |
Fri, 16 April 2004 07:50  |
Eclipse User |
|
|
|
--------------65B7F0FFEBF87274A9D96A67
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Joachim,
For this particular scenario, the following should work:
elemDecl.setAnonymousTypeDefinition((XSDSimpleTypeDefinition )std.cloneConcreteComponent(true,
false));
Joachim Lusiardi wrote:
> Hi!
> My problem is the following:
> I have one larger XSD Schema looking like the following:
>
> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" >
> <xs:element name="Name" type="MyComplexType" />
>
> <xs:complexType name="MyComplexType">
> <xs:sequence minOccurs="1" maxOccurs="1">
> <xs:element name="vorname">
> <xs:simpleType >
> <xs:restriction base="xs:string">
> <xs:minLength value="4"/>
> </xs:restriction>
> </xs:simpleType>
> </xs:element>
> <xs:element name="nachname" type="xs:string" />
> </xs:sequence>
> <xs:attribute name="Geburtstag" type="xs:date" />
> </xs:complexType>
>
> </xs:schema>
>
> and i want to transform it into something like this:
>
> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" >
> <xs:element name="Name" type="MyComplexType" />
>
> <xs:complexType name="MyComplexType">
> <xs:sequence minOccurs="1" maxOccurs="1">
> <xs:element name="vorname">
> <xs:simpleType >
> <xs:restriction base="xs:string">
> <xs:minLength value="4"/>
> </xs:restriction>
> </xs:simpleType>
> </xs:element>
> <xs:element name="nachname" type="xs:string" />
> </xs:sequence>
> <xs:attribute name="Geburtstag" type="xs:date" />
> </xs:complexType>
>
> <xs:element name="NameTest">
> <xs:simpleType >
> <xs:restriction base="xs:string">
> <xs:minLength value="4"/>
> </xs:restriction>
> </xs:simpleType>
> </xs:element>
> </xs:schema>
>
> this would enable me to create XML instance files with NameTest as root
> element.
>
> An now the big question:
> Lets asume i have the XSDSimpleTypeDefiniton of the anonymous type
> inside the embeded "vorname" element. How can a transfer this to an
> newly created XSDELementDeclaration?
>
> I tried the following code:
>
> XSDSimpleTypeDefinition std = getSimpleTypeFromOldSchema();
> XSDElementDeclaration elemDecl =
> xsdFactory.createXSDElementDeclaration();
> elemDecl.setName("NameTest");
> newSchema.getContents().add(elemDecl);
> elemDecl.setTypeDefinition(std);
>
> this produces an element declaration in the new schema that looks like this:
>
> <?xml version="1.0" encoding="UTF-8"?>
> <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
> <xsd:element name="test1" type="vorname_._type"/>
> </xsd:schema>
>
> So what can i do to achieve what i want to have?
>
> thanks for your answers.
> greets Joachim Lusiardi
--------------65B7F0FFEBF87274A9D96A67
Content-Type: text/html; charset=us-ascii
Content-Transfer-Encoding: 7bit
<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
Joachim,
<p>For this particular scenario, the following should work:
<blockquote> elemDecl.setAnonymousTypeDefinition((XSDSimpleTypeDefinition )std.cloneConcreteComponent(true,
false));</blockquote>
<p><br>Joachim Lusiardi wrote:
<blockquote TYPE=CITE>Hi!
<br>My problem is the following:
<br>I have one larger XSD Schema looking like the following:
<p><xs:schema xmlns:xs="<a href="http://www.w3.org/2001/XMLSchema">http://www.w3.org/2001/XMLSchema</a>"
>
<br> <xs:element name="Name" type="MyComplexType"
/>
<p> <xs:complexType name="MyComplexType">
<br> <xs:sequence minOccurs="1"
maxOccurs="1">
<br>
<xs:element name="vorname">
<br>
<xs:simpleType >
<br>
<xs:restriction base="xs:string">
<br>
<xs:minLength value="4"/>
<br>
</xs:restriction>
<br>
</xs:simpleType>
<br>
</xs:element>
<br>
<xs:element name="nachname" type="xs:string" />
<br> </xs:sequence>
<br> <xs:attribute name="Geburtstag"
type="xs:date" />
<br> </xs:complexType>
<p></xs:schema>
<p>and i want to transform it into something like this:
<p><xs:schema xmlns:xs="<a href="http://www.w3.org/2001/XMLSchema">http://www.w3.org/2001/XMLSchema</a>"
>
<br> <xs:element name="Name" type="MyComplexType"
/>
<p> <xs:complexType name="MyComplexType">
<br> <xs:sequence minOccurs="1"
maxOccurs="1">
<br>
<xs:element name="vorname">
<br>
<xs:simpleType >
<br>
<xs:restriction base="xs:string">
<br>
<xs:minLength value="4"/>
<br>
</xs:restriction>
<br>
</xs:simpleType>
<br>
</xs:element>
<br>
<xs:element name="nachname" type="xs:string" />
<br> </xs:sequence>
<br> <xs:attribute name="Geburtstag"
type="xs:date" />
<br> </xs:complexType>
<p> <xs:element name="NameTest">
<br> <xs:simpleType >
<br> <xs:restriction
base="xs:string">
<br>
<xs:minLength value="4"/>
<br> </xs:restriction>
<br> </xs:simpleType>
<br> </xs:element>
<br></xs:schema>
<p>this would enable me to create XML instance files with NameTest as root
<br>element.
<p>An now the big question:
<br>Lets asume i have the XSDSimpleTypeDefiniton of the anonymous type
<br>inside the embeded "vorname" element. How can a transfer this to an
<br>newly created XSDELementDeclaration?
<p>I tried the following code:
<p>XSDSimpleTypeDefinition std = getSimpleTypeFromOldSchema();
<br>XSDElementDeclaration elemDecl =
<br>
xsdFactory.createXSDElementDeclaration();
<br>elemDecl.setName("NameTest");
<br>newSchema.getContents().add(elemDecl);
<br>elemDecl.setTypeDefinition(std);
<p>this produces an element declaration in the new schema that looks like
this:
<p><?xml version="1.0" encoding="UTF-8"?>
<br><xsd:schema xmlns:xsd="<a href="http://www.w3.org/2001/XMLSchema">http://www.w3.org/2001/XMLSchema</a>">
<br><xsd:element name="test1" type="vorname_._type"/>
<br></xsd:schema>
<p>So what can i do to achieve what i want to have?
<p>thanks for your answers.
<br>greets Joachim Lusiardi</blockquote>
</html>
--------------65B7F0FFEBF87274A9D96A67--
|
|
|
Re: Problem with transferring a type definition between two schemas [message #585676 is a reply to message #41528] |
Fri, 16 April 2004 07:55  |
Eclipse User |
|
|
|
Hi,
Thanks for your quick answer. Your code works perfectly. You saved me a
lot of time.
greets
Joachim Lusiardi
Ed Merks wrote:
> Joachim,
>
> For this particular scenario, the following should work:
>
> elemDecl.setAnonymousTypeDefinition((XSDSimpleTypeDefinition )std.cloneConcreteComponent(true,
> false));
>
>
> Joachim Lusiardi wrote:
>
>> Hi!
>> My problem is the following:
>> I have one larger XSD Schema looking like the following:
>>
>> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" >
>> <xs:element name="Name" type="MyComplexType" />
>>
>> <xs:complexType name="MyComplexType">
>> <xs:sequence minOccurs="1" maxOccurs="1">
>> <xs:element name="vorname">
>> <xs:simpleType >
>> <xs:restriction base="xs:string">
>> <xs:minLength value="4"/>
>> </xs:restriction>
>> </xs:simpleType>
>> </xs:element>
>> <xs:element name="nachname" type="xs:string" />
>> </xs:sequence>
>> <xs:attribute name="Geburtstag" type="xs:date" />
>> </xs:complexType>
>>
>> </xs:schema>
>>
>> and i want to transform it into something like this:
>>
>> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" >
>> <xs:element name="Name" type="MyComplexType" />
>>
>> <xs:complexType name="MyComplexType">
>> <xs:sequence minOccurs="1" maxOccurs="1">
>> <xs:element name="vorname">
>> <xs:simpleType >
>> <xs:restriction base="xs:string">
>> <xs:minLength value="4"/>
>> </xs:restriction>
>> </xs:simpleType>
>> </xs:element>
>> <xs:element name="nachname" type="xs:string" />
>> </xs:sequence>
>> <xs:attribute name="Geburtstag" type="xs:date" />
>> </xs:complexType>
>>
>> <xs:element name="NameTest">
>> <xs:simpleType >
>> <xs:restriction base="xs:string">
>> <xs:minLength value="4"/>
>> </xs:restriction>
>> </xs:simpleType>
>> </xs:element>
>> </xs:schema>
>>
>> this would enable me to create XML instance files with NameTest as root
>> element.
>>
>> An now the big question:
>> Lets asume i have the XSDSimpleTypeDefiniton of the anonymous type
>> inside the embeded "vorname" element. How can a transfer this to an
>> newly created XSDELementDeclaration?
>>
>> I tried the following code:
>>
>> XSDSimpleTypeDefinition std = getSimpleTypeFromOldSchema();
>> XSDElementDeclaration elemDecl =
>> xsdFactory.createXSDElementDeclaration();
>> elemDecl.setName("NameTest");
>> newSchema.getContents().add(elemDecl);
>> elemDecl.setTypeDefinition(std);
>>
>> this produces an element declaration in the new schema that looks like
>> this:
>>
>> <?xml version="1.0" encoding="UTF-8"?>
>> <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
>> <xsd:element name="test1" type="vorname_._type"/>
>> </xsd:schema>
>>
>> So what can i do to achieve what i want to have?
>>
>> thanks for your answers.
>> greets Joachim Lusiardi
>>
|
|
|
Powered by
FUDForum. Page generated in 0.05363 seconds