Home » Archived » XML Schema Definition (XSD) » Moving components from one XSD schema to another Ctd
|
Re: Moving components from one XSD schema to another Ctd [message #37786 is a reply to message #37753] |
Thu, 04 March 2004 13:47 |
Eclipse User |
|
|
|
Originally posted by: merks.ca.ibm.com
Hayen,
Have you tried calling updateElement on the schema at the end?
Hayden Marchant wrote:
> Hi,
>
> I need to merge one XSD schema into another XSD Schema. I wrote code to do
> this that works in the case that 1 schema includes the other schema -
> works fantastically using the help that you gave me on July 31 2003:
>
> You suggested: You can only merge included schemas into a single schema
> since imports imply a
> different namespace and each different target namespace will require a
> different schema document to be defined. If you want something to be
> contained by a particular schema you would add it to the list returned by
> xsdSchema.getContents(); adding it to a new container will remove it from
> its
> old container automatically.
>
> However, I now have a problem when the first schema imports the second
> schema. The problem is how Eclipse manages the namespace when an object is
> moved from one schema to another. In my example, I have an element in
> schema A, which is of type CT which is imported from schema B. When I add
> the objects from the imported schema (B) to the main schema, the namespace
> is lost - which is great since I want one big schema. However, the element
> in A that references that complex type that was in B but is now in A
> refers to it with the namespace prefix. I would have expected that the
> dependency mechanism of Eclipse model would have updated the referring
> element's reference before moving the complex type- this does not seem to
> be happening.
>
> In order to see what I mean try using the 2 xsds samples that come with
> XML Spy - OrgChart.xsd and Address.xsd. OrgChart.xsd imports address.xsd
> and when I do orgChart.getContents().add(addressComplexType). When I try
> to parse this new merged schema after saving the merged to disk, I get the
> following error:
>
> XSD: Type reference 'http://www.altova.com/IPO#US-Address' is unresolved.
>
> Here is a snippet of my merged schema:
>
> <xsd:complexType name="OfficeType">
> <xsd:sequence>
> <xsd:element ref="Name"/>
> <xsd:element ref="Desc"/>
> <xsd:element name="Address" type="ipo:US-Address"/>
> <xsd:element name="Phone" type="xsd:string"/>
> <xsd:element name="Fax" type="xsd:string"/>
>
> Note that the complex type US-Address is no longer in namespace ipo but
> the element reference thinks that it is.
>
> Thanks,
> Hayden Marchant
|
|
|
Re: Moving components from one XSD schema to another Ctd [message #37849 is a reply to message #37786] |
Thu, 04 March 2004 15:20 |
Hayden Marchant Messages: 90 Registered: July 2009 |
Member |
|
|
This didn't seem to change anything. I take it that updateElement is a
recursive method and that it would go down the whole tree and call
updateElement on each member? Is there anyway I can make sure that this is
happening.
Thanks
Ed Merks wrote:
> Hayen,
> Have you tried calling updateElement on the schema at the end?
> Hayden Marchant wrote:
> > Hi,
> >
> > I need to merge one XSD schema into another XSD Schema. I wrote code to do
> > this that works in the case that 1 schema includes the other schema -
> > works fantastically using the help that you gave me on July 31 2003:
> >
> > You suggested: You can only merge included schemas into a single schema
> > since imports imply a
> > different namespace and each different target namespace will require a
> > different schema document to be defined. If you want something to be
> > contained by a particular schema you would add it to the list returned by
> > xsdSchema.getContents(); adding it to a new container will remove it from
> > its
> > old container automatically.
> >
> > However, I now have a problem when the first schema imports the second
> > schema. The problem is how Eclipse manages the namespace when an object is
> > moved from one schema to another. In my example, I have an element in
> > schema A, which is of type CT which is imported from schema B. When I add
> > the objects from the imported schema (B) to the main schema, the namespace
> > is lost - which is great since I want one big schema. However, the element
> > in A that references that complex type that was in B but is now in A
> > refers to it with the namespace prefix. I would have expected that the
> > dependency mechanism of Eclipse model would have updated the referring
> > element's reference before moving the complex type- this does not seem to
> > be happening.
> >
> > In order to see what I mean try using the 2 xsds samples that come with
> > XML Spy - OrgChart.xsd and Address.xsd. OrgChart.xsd imports address.xsd
> > and when I do orgChart.getContents().add(addressComplexType). When I try
> > to parse this new merged schema after saving the merged to disk, I get the
> > following error:
> >
> > XSD: Type reference 'http://www.altova.com/IPO#US-Address' is unresolved.
> >
> > Here is a snippet of my merged schema:
> >
> > <xsd:complexType name="OfficeType">
> > <xsd:sequence>
> > <xsd:element ref="Name"/>
> > <xsd:element ref="Desc"/>
> > <xsd:element name="Address" type="ipo:US-Address"/>
> > <xsd:element name="Phone" type="xsd:string"/>
> > <xsd:element name="Fax" type="xsd:string"/>
> >
> > Note that the complex type US-Address is no longer in namespace ipo but
> > the element reference thinks that it is.
> >
> > Thanks,
> > Hayden Marchant
|
|
|
Re: Moving components from one XSD schema to another Ctd [message #37882 is a reply to message #37849] |
Thu, 04 March 2004 16:45 |
Eclipse User |
|
|
|
Originally posted by: merks.ca.ibm.com
Hayden,
Maybe/probably if you do xsdSchema.setIncrementalUpdate(false), make your changes
to it, and then call updateElement, it will work; you can set it back to true
after. (I suspect that the incremental updates are re-resolving the names as
specific in the DOM.)
Hayden Marchant wrote:
> This didn't seem to change anything. I take it that updateElement is a
> recursive method and that it would go down the whole tree and call
> updateElement on each member? Is there anyway I can make sure that this is
> happening.
>
> Thanks
>
> Ed Merks wrote:
>
> > Hayen,
>
> > Have you tried calling updateElement on the schema at the end?
>
> > Hayden Marchant wrote:
>
> > > Hi,
> > >
> > > I need to merge one XSD schema into another XSD Schema. I wrote code to do
> > > this that works in the case that 1 schema includes the other schema -
> > > works fantastically using the help that you gave me on July 31 2003:
> > >
> > > You suggested: You can only merge included schemas into a single schema
> > > since imports imply a
> > > different namespace and each different target namespace will require a
> > > different schema document to be defined. If you want something to be
> > > contained by a particular schema you would add it to the list returned by
> > > xsdSchema.getContents(); adding it to a new container will remove it from
> > > its
> > > old container automatically.
> > >
> > > However, I now have a problem when the first schema imports the second
> > > schema. The problem is how Eclipse manages the namespace when an object is
> > > moved from one schema to another. In my example, I have an element in
> > > schema A, which is of type CT which is imported from schema B. When I add
> > > the objects from the imported schema (B) to the main schema, the namespace
> > > is lost - which is great since I want one big schema. However, the element
> > > in A that references that complex type that was in B but is now in A
> > > refers to it with the namespace prefix. I would have expected that the
> > > dependency mechanism of Eclipse model would have updated the referring
> > > element's reference before moving the complex type- this does not seem to
> > > be happening.
> > >
> > > In order to see what I mean try using the 2 xsds samples that come with
> > > XML Spy - OrgChart.xsd and Address.xsd. OrgChart.xsd imports address.xsd
> > > and when I do orgChart.getContents().add(addressComplexType). When I try
> > > to parse this new merged schema after saving the merged to disk, I get the
> > > following error:
> > >
> > > XSD: Type reference 'http://www.altova.com/IPO#US-Address' is unresolved.
> > >
> > > Here is a snippet of my merged schema:
> > >
> > > <xsd:complexType name="OfficeType">
> > > <xsd:sequence>
> > > <xsd:element ref="Name"/>
> > > <xsd:element ref="Desc"/>
> > > <xsd:element name="Address" type="ipo:US-Address"/>
> > > <xsd:element name="Phone" type="xsd:string"/>
> > > <xsd:element name="Fax" type="xsd:string"/>
> > >
> > > Note that the complex type US-Address is no longer in namespace ipo but
> > > the element reference thinks that it is.
> > >
> > > Thanks,
> > > Hayden Marchant
|
|
|
Re: Moving components from one XSD schema to another Ctd [message #38024 is a reply to message #37882] |
Mon, 08 March 2004 07:57 |
Hayden Marchant Messages: 90 Registered: July 2009 |
Member |
|
|
Thanks - it worked!!!
Ed Merks wrote:
> Hayden,
> Maybe/probably if you do xsdSchema.setIncrementalUpdate(false), make your
changes
> to it, and then call updateElement, it will work; you can set it back to true
> after. (I suspect that the incremental updates are re-resolving the names as
> specific in the DOM.)
> Hayden Marchant wrote:
> > This didn't seem to change anything. I take it that updateElement is a
> > recursive method and that it would go down the whole tree and call
> > updateElement on each member? Is there anyway I can make sure that this is
> > happening.
> >
> > Thanks
> >
> > Ed Merks wrote:
> >
> > > Hayen,
> >
> > > Have you tried calling updateElement on the schema at the end?
> >
> > > Hayden Marchant wrote:
> >
> > > > Hi,
> > > >
> > > > I need to merge one XSD schema into another XSD Schema. I wrote code
to do
> > > > this that works in the case that 1 schema includes the other schema -
> > > > works fantastically using the help that you gave me on July 31 2003:
> > > >
> > > > You suggested: You can only merge included schemas into a single schema
> > > > since imports imply a
> > > > different namespace and each different target namespace will require a
> > > > different schema document to be defined. If you want something to be
> > > > contained by a particular schema you would add it to the list returned
by
> > > > xsdSchema.getContents(); adding it to a new container will remove it
from
> > > > its
> > > > old container automatically.
> > > >
> > > > However, I now have a problem when the first schema imports the second
> > > > schema. The problem is how Eclipse manages the namespace when an
object is
> > > > moved from one schema to another. In my example, I have an element in
> > > > schema A, which is of type CT which is imported from schema B. When I
add
> > > > the objects from the imported schema (B) to the main schema, the
namespace
> > > > is lost - which is great since I want one big schema. However, the
element
> > > > in A that references that complex type that was in B but is now in A
> > > > refers to it with the namespace prefix. I would have expected that the
> > > > dependency mechanism of Eclipse model would have updated the referring
> > > > element's reference before moving the complex type- this does not
seem to
> > > > be happening.
> > > >
> > > > In order to see what I mean try using the 2 xsds samples that come with
> > > > XML Spy - OrgChart.xsd and Address.xsd. OrgChart.xsd imports
address.xsd
> > > > and when I do orgChart.getContents().add(addressComplexType). When I
try
> > > > to parse this new merged schema after saving the merged to disk, I get
the
> > > > following error:
> > > >
> > > > XSD: Type reference 'http://www.altova.com/IPO#US-Address' is
unresolved.
> > > >
> > > > Here is a snippet of my merged schema:
> > > >
> > > > <xsd:complexType name="OfficeType">
> > > > <xsd:sequence>
> > > > <xsd:element ref="Name"/>
> > > > <xsd:element ref="Desc"/>
> > > > <xsd:element name="Address" type="ipo:US-Address"/>
> > > > <xsd:element name="Phone" type="xsd:string"/>
> > > > <xsd:element name="Fax" type="xsd:string"/>
> > > >
> > > > Note that the complex type US-Address is no longer in namespace ipo but
> > > > the element reference thinks that it is.
> > > >
> > > > Thanks,
> > > > Hayden Marchant
|
|
|
Re: Moving components from one XSD schema to another Ctd [message #583687 is a reply to message #37753] |
Thu, 04 March 2004 13:47 |
Ed Merks Messages: 33216 Registered: July 2009 |
Senior Member |
|
|
Hayen,
Have you tried calling updateElement on the schema at the end?
Hayden Marchant wrote:
> Hi,
>
> I need to merge one XSD schema into another XSD Schema. I wrote code to do
> this that works in the case that 1 schema includes the other schema -
> works fantastically using the help that you gave me on July 31 2003:
>
> You suggested: You can only merge included schemas into a single schema
> since imports imply a
> different namespace and each different target namespace will require a
> different schema document to be defined. If you want something to be
> contained by a particular schema you would add it to the list returned by
> xsdSchema.getContents(); adding it to a new container will remove it from
> its
> old container automatically.
>
> However, I now have a problem when the first schema imports the second
> schema. The problem is how Eclipse manages the namespace when an object is
> moved from one schema to another. In my example, I have an element in
> schema A, which is of type CT which is imported from schema B. When I add
> the objects from the imported schema (B) to the main schema, the namespace
> is lost - which is great since I want one big schema. However, the element
> in A that references that complex type that was in B but is now in A
> refers to it with the namespace prefix. I would have expected that the
> dependency mechanism of Eclipse model would have updated the referring
> element's reference before moving the complex type- this does not seem to
> be happening.
>
> In order to see what I mean try using the 2 xsds samples that come with
> XML Spy - OrgChart.xsd and Address.xsd. OrgChart.xsd imports address.xsd
> and when I do orgChart.getContents().add(addressComplexType). When I try
> to parse this new merged schema after saving the merged to disk, I get the
> following error:
>
> XSD: Type reference 'http://www.altova.com/IPO#US-Address' is unresolved.
>
> Here is a snippet of my merged schema:
>
> <xsd:complexType name="OfficeType">
> <xsd:sequence>
> <xsd:element ref="Name"/>
> <xsd:element ref="Desc"/>
> <xsd:element name="Address" type="ipo:US-Address"/>
> <xsd:element name="Phone" type="xsd:string"/>
> <xsd:element name="Fax" type="xsd:string"/>
>
> Note that the complex type US-Address is no longer in namespace ipo but
> the element reference thinks that it is.
>
> Thanks,
> Hayden Marchant
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
Re: Moving components from one XSD schema to another Ctd [message #583710 is a reply to message #37786] |
Thu, 04 March 2004 15:20 |
Hayden Marchant Messages: 90 Registered: July 2009 |
Member |
|
|
This didn't seem to change anything. I take it that updateElement is a
recursive method and that it would go down the whole tree and call
updateElement on each member? Is there anyway I can make sure that this is
happening.
Thanks
Ed Merks wrote:
> Hayen,
> Have you tried calling updateElement on the schema at the end?
> Hayden Marchant wrote:
> > Hi,
> >
> > I need to merge one XSD schema into another XSD Schema. I wrote code to do
> > this that works in the case that 1 schema includes the other schema -
> > works fantastically using the help that you gave me on July 31 2003:
> >
> > You suggested: You can only merge included schemas into a single schema
> > since imports imply a
> > different namespace and each different target namespace will require a
> > different schema document to be defined. If you want something to be
> > contained by a particular schema you would add it to the list returned by
> > xsdSchema.getContents(); adding it to a new container will remove it from
> > its
> > old container automatically.
> >
> > However, I now have a problem when the first schema imports the second
> > schema. The problem is how Eclipse manages the namespace when an object is
> > moved from one schema to another. In my example, I have an element in
> > schema A, which is of type CT which is imported from schema B. When I add
> > the objects from the imported schema (B) to the main schema, the namespace
> > is lost - which is great since I want one big schema. However, the element
> > in A that references that complex type that was in B but is now in A
> > refers to it with the namespace prefix. I would have expected that the
> > dependency mechanism of Eclipse model would have updated the referring
> > element's reference before moving the complex type- this does not seem to
> > be happening.
> >
> > In order to see what I mean try using the 2 xsds samples that come with
> > XML Spy - OrgChart.xsd and Address.xsd. OrgChart.xsd imports address.xsd
> > and when I do orgChart.getContents().add(addressComplexType). When I try
> > to parse this new merged schema after saving the merged to disk, I get the
> > following error:
> >
> > XSD: Type reference 'http://www.altova.com/IPO#US-Address' is unresolved.
> >
> > Here is a snippet of my merged schema:
> >
> > <xsd:complexType name="OfficeType">
> > <xsd:sequence>
> > <xsd:element ref="Name"/>
> > <xsd:element ref="Desc"/>
> > <xsd:element name="Address" type="ipo:US-Address"/>
> > <xsd:element name="Phone" type="xsd:string"/>
> > <xsd:element name="Fax" type="xsd:string"/>
> >
> > Note that the complex type US-Address is no longer in namespace ipo but
> > the element reference thinks that it is.
> >
> > Thanks,
> > Hayden Marchant
|
|
|
Re: Moving components from one XSD schema to another Ctd [message #583726 is a reply to message #37849] |
Thu, 04 March 2004 16:45 |
Ed Merks Messages: 33216 Registered: July 2009 |
Senior Member |
|
|
Hayden,
Maybe/probably if you do xsdSchema.setIncrementalUpdate(false), make your changes
to it, and then call updateElement, it will work; you can set it back to true
after. (I suspect that the incremental updates are re-resolving the names as
specific in the DOM.)
Hayden Marchant wrote:
> This didn't seem to change anything. I take it that updateElement is a
> recursive method and that it would go down the whole tree and call
> updateElement on each member? Is there anyway I can make sure that this is
> happening.
>
> Thanks
>
> Ed Merks wrote:
>
> > Hayen,
>
> > Have you tried calling updateElement on the schema at the end?
>
> > Hayden Marchant wrote:
>
> > > Hi,
> > >
> > > I need to merge one XSD schema into another XSD Schema. I wrote code to do
> > > this that works in the case that 1 schema includes the other schema -
> > > works fantastically using the help that you gave me on July 31 2003:
> > >
> > > You suggested: You can only merge included schemas into a single schema
> > > since imports imply a
> > > different namespace and each different target namespace will require a
> > > different schema document to be defined. If you want something to be
> > > contained by a particular schema you would add it to the list returned by
> > > xsdSchema.getContents(); adding it to a new container will remove it from
> > > its
> > > old container automatically.
> > >
> > > However, I now have a problem when the first schema imports the second
> > > schema. The problem is how Eclipse manages the namespace when an object is
> > > moved from one schema to another. In my example, I have an element in
> > > schema A, which is of type CT which is imported from schema B. When I add
> > > the objects from the imported schema (B) to the main schema, the namespace
> > > is lost - which is great since I want one big schema. However, the element
> > > in A that references that complex type that was in B but is now in A
> > > refers to it with the namespace prefix. I would have expected that the
> > > dependency mechanism of Eclipse model would have updated the referring
> > > element's reference before moving the complex type- this does not seem to
> > > be happening.
> > >
> > > In order to see what I mean try using the 2 xsds samples that come with
> > > XML Spy - OrgChart.xsd and Address.xsd. OrgChart.xsd imports address.xsd
> > > and when I do orgChart.getContents().add(addressComplexType). When I try
> > > to parse this new merged schema after saving the merged to disk, I get the
> > > following error:
> > >
> > > XSD: Type reference 'http://www.altova.com/IPO#US-Address' is unresolved.
> > >
> > > Here is a snippet of my merged schema:
> > >
> > > <xsd:complexType name="OfficeType">
> > > <xsd:sequence>
> > > <xsd:element ref="Name"/>
> > > <xsd:element ref="Desc"/>
> > > <xsd:element name="Address" type="ipo:US-Address"/>
> > > <xsd:element name="Phone" type="xsd:string"/>
> > > <xsd:element name="Fax" type="xsd:string"/>
> > >
> > > Note that the complex type US-Address is no longer in namespace ipo but
> > > the element reference thinks that it is.
> > >
> > > Thanks,
> > > Hayden Marchant
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
Re: Moving components from one XSD schema to another Ctd [message #583814 is a reply to message #37882] |
Mon, 08 March 2004 07:57 |
Hayden Marchant Messages: 90 Registered: July 2009 |
Member |
|
|
Thanks - it worked!!!
Ed Merks wrote:
> Hayden,
> Maybe/probably if you do xsdSchema.setIncrementalUpdate(false), make your
changes
> to it, and then call updateElement, it will work; you can set it back to true
> after. (I suspect that the incremental updates are re-resolving the names as
> specific in the DOM.)
> Hayden Marchant wrote:
> > This didn't seem to change anything. I take it that updateElement is a
> > recursive method and that it would go down the whole tree and call
> > updateElement on each member? Is there anyway I can make sure that this is
> > happening.
> >
> > Thanks
> >
> > Ed Merks wrote:
> >
> > > Hayen,
> >
> > > Have you tried calling updateElement on the schema at the end?
> >
> > > Hayden Marchant wrote:
> >
> > > > Hi,
> > > >
> > > > I need to merge one XSD schema into another XSD Schema. I wrote code
to do
> > > > this that works in the case that 1 schema includes the other schema -
> > > > works fantastically using the help that you gave me on July 31 2003:
> > > >
> > > > You suggested: You can only merge included schemas into a single schema
> > > > since imports imply a
> > > > different namespace and each different target namespace will require a
> > > > different schema document to be defined. If you want something to be
> > > > contained by a particular schema you would add it to the list returned
by
> > > > xsdSchema.getContents(); adding it to a new container will remove it
from
> > > > its
> > > > old container automatically.
> > > >
> > > > However, I now have a problem when the first schema imports the second
> > > > schema. The problem is how Eclipse manages the namespace when an
object is
> > > > moved from one schema to another. In my example, I have an element in
> > > > schema A, which is of type CT which is imported from schema B. When I
add
> > > > the objects from the imported schema (B) to the main schema, the
namespace
> > > > is lost - which is great since I want one big schema. However, the
element
> > > > in A that references that complex type that was in B but is now in A
> > > > refers to it with the namespace prefix. I would have expected that the
> > > > dependency mechanism of Eclipse model would have updated the referring
> > > > element's reference before moving the complex type- this does not
seem to
> > > > be happening.
> > > >
> > > > In order to see what I mean try using the 2 xsds samples that come with
> > > > XML Spy - OrgChart.xsd and Address.xsd. OrgChart.xsd imports
address.xsd
> > > > and when I do orgChart.getContents().add(addressComplexType). When I
try
> > > > to parse this new merged schema after saving the merged to disk, I get
the
> > > > following error:
> > > >
> > > > XSD: Type reference 'http://www.altova.com/IPO#US-Address' is
unresolved.
> > > >
> > > > Here is a snippet of my merged schema:
> > > >
> > > > <xsd:complexType name="OfficeType">
> > > > <xsd:sequence>
> > > > <xsd:element ref="Name"/>
> > > > <xsd:element ref="Desc"/>
> > > > <xsd:element name="Address" type="ipo:US-Address"/>
> > > > <xsd:element name="Phone" type="xsd:string"/>
> > > > <xsd:element name="Fax" type="xsd:string"/>
> > > >
> > > > Note that the complex type US-Address is no longer in namespace ipo but
> > > > the element reference thinks that it is.
> > > >
> > > > Thanks,
> > > > Hayden Marchant
|
|
|
Goto Forum:
Current Time: Fri Sep 20 06:38:35 GMT 2024
Powered by FUDForum. Page generated in 0.05745 seconds
|