Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » XML Schema Definition (XSD) » Problem with transferring a type definition between two schemas
Problem with transferring a type definition between two schemas [message #585641] Fri, 16 April 2004 11:11
Joachim Lusiardi is currently offline Joachim LusiardiFriend
Messages: 18
Registered: July 2009
Junior Member
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
Previous Topic:traversing hierarchy of particles
Next Topic:Problem with transferring a type definition between two schemas
Goto Forum:
  


Current Time: Fri Oct 30 19:26:47 GMT 2020

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

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

Back to the top