Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » XML Schema Definition (XSD) » Determining if an <include>'d schema has a defined target namespace
Determining if an <include>'d schema has a defined target namespace [message #59082] Thu, 07 April 2005 10:37 Go to next message
Steve Speicher is currently offline Steve Speicher
Messages: 83
Registered: July 2009
Member

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

Hi,

I've got an included schema that doesn't have a targetNamespace
defined. I'd like to determine that (it isn't defined) but the method
XSDSchema.getTargetNamespace() returns the "incorporated" schema's
target namespace (since the top-level schema defines a target namespace).

Is it possible to determine this?

Sample schema:

<!-- top-level.xsd -->
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://www.ibm.com/samples">
<xs:include schemaLocation="include.xsd"/>
</xs:schema>

<!-- include.xsd -->
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:attribute name="dummy" type="xs:string"/>
</xs:schema>


Attempt to get using something like:

Resource res = ...;
XSDSchema topLevelSchema = (XSDSchema)res.getContents().get(0);
XSDInclude xsdInclude = (XSDInclude)topLevelSchema.getContents().get(0);
String tns = xsdInclude.getIncorporatedSchema().getTargetNamespace();
// tns is set to the top-level tns


Thanks in advance,
Steve

--------------090509080408010309000802
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">
<title></title>
</head>
<body bgcolor="#ffffff" text="#000000">
Hi,<br>
<br>
I've got an included schema that doesn't have a targetNamespace
defined.&nbsp; I'd like to determine that (it isn't defined) but the method
XSDSchema.getTargetNamespace() returns the "incorporated" schema's
target namespace (since the top-level schema defines a target
namespace).<br>
<br>
Is it possible to determine this?<br>
<br>
Sample schema:<br>
<blockquote><tt>&lt;!-- top-level.xsd --&gt;</tt><br>
<tt>&lt;xs:schema xmlns:xs=<a class="moz-txt-link-rfc2396E" href="http://www.w3.org/2001/XMLSchema">"http://www.w3.org/2001/XMLSchema"</a>
targetNamespace=<a class="moz-txt-link-rfc2396E" href="http://www.ibm.com/samples">"http://www.ibm.com/samples"</a>&gt;</tt><br>
<tt>&nbsp; &lt;xs:include schemaLocation="include.xsd"/&gt;</tt><br>
<tt>&lt;/xs:schema&gt;</tt><br>
<br>
<tt>&lt;!-- include.xsd --&gt;</tt><br>
<tt>&lt;xs:schema xmlns:xs=<a class="moz-txt-link-rfc2396E" href="http://www.w3.org/2001/XMLSchema">"http://www.w3.org/2001/XMLSchema"</a>&gt;</tt><br>
<tt>&nbsp; &lt;xs:attribute name="dummy" type="xs:string"/&gt;</tt><br>
<tt>&lt;/xs:schema&gt;</tt><br>
</blockquote>
<br>
Attempt to get using something like:<br>
<br>
<blockquote><tt>Resource res&nbsp; = ...;</tt><br>
<tt>XSDSchema topLevelSchema = (XSDSchema)res.getContents().get(0);</tt><br>
<tt>XSDInclude xsdInclude =
(XSDInclude)topLevelSchema.getContents().get(0);</tt><br>
<tt>String tns =
xsdInclude.getIncorporatedSchema().getTargetNamespace();</tt ><br>
<tt>// tns is set to the top-level tns</tt><br>
</blockquote>
<br>
Thanks in advance,<br>
Steve<br>
<a class="moz-txt-link-rfc2396E" href="http://tempuri.org/MySchema.xsd"></a>
</body>
</html>

--------------090509080408010309000802--
Re: Determining if an <include>'d schema has a defined target namespace [message #59110 is a reply to message #59082] Thu, 07 April 2005 10:49 Go to previous message
Eclipse User
Originally posted by: merks.ca.ibm.com

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

Steve,

You can access the resolved schema to get that:

String tns = xsdInclude.getResolvedSchema().getTargetNamespace()

Given an XSDSchema, you can also call getOriginalVersion() to determine
the schema from which it was cloned.


Steve Speicher wrote:

> Hi,
>
> I've got an included schema that doesn't have a targetNamespace
> defined. I'd like to determine that (it isn't defined) but the method
> XSDSchema.getTargetNamespace() returns the "incorporated" schema's
> target namespace (since the top-level schema defines a target namespace).
>
> Is it possible to determine this?
>
> Sample schema:
>
> <!-- top-level.xsd -->
> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
> targetNamespace="http://www.ibm.com/samples">
> <xs:include schemaLocation="include.xsd"/>
> </xs:schema>
>
> <!-- include.xsd -->
> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
> <xs:attribute name="dummy" type="xs:string"/>
> </xs:schema>
>
>
> Attempt to get using something like:
>
> Resource res = ...;
> XSDSchema topLevelSchema = (XSDSchema)res.getContents().get(0);
> XSDInclude xsdInclude =
> (XSDInclude)topLevelSchema.getContents().get(0);
> String tns = xsdInclude.getIncorporatedSchema().getTargetNamespace();
> // tns is set to the top-level tns
>
>
> Thanks in advance,
> Steve



--------------080706070905030606070404
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">
Steve,<br>
<br>
You can access the resolved schema to get that:<br>
<blockquote><tt>String tns =
xsdInclude.getResolvedSchema().getTargetNamespace()</tt><br >
</blockquote>
Given an XSDSchema, you can also call getOriginalVersion() to determine
the schema from which it was cloned.<br>
<br>
<br>
Steve Speicher wrote:
<blockquote cite="midd33grh$dob$1@news.eclipse.org" type="cite">
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
<title></title>
Hi,<br>
<br>
I've got an included schema that doesn't have a targetNamespace
defined.&nbsp; I'd like to determine that (it isn't defined) but the method
XSDSchema.getTargetNamespace() returns the "incorporated" schema's
target namespace (since the top-level schema defines a target
namespace).<br>
<br>
Is it possible to determine this?<br>
<br>
Sample schema:<br>
<blockquote><tt>&lt;!-- top-level.xsd --&gt;</tt><br>
<tt>&lt;xs:schema xmlns:xs=<a class="moz-txt-link-rfc2396E"
href="http://www.w3.org/2001/XMLSchema">"http://www.w3.org/2001/XMLSchema"</a>
targetNamespace=<a class="moz-txt-link-rfc2396E"
href="http://www.ibm.com/samples">"http://www.ibm.com/samples"</a>&gt;</tt><br>
<tt>&nbsp; &lt;xs:include schemaLocation="include.xsd"/&gt;</tt><br>
<tt>&lt;/xs:schema&gt;</tt><br>
<br>
<tt>&lt;!-- include.xsd --&gt;</tt><br>
<tt>&lt;xs:schema xmlns:xs=<a class="moz-txt-link-rfc2396E"
href="http://www.w3.org/2001/XMLSchema">"http://www.w3.org/2001/XMLSchema"</a>&gt;</tt><br>
<tt>&nbsp; &lt;xs:attribute name="dummy" type="xs:string"/&gt;</tt><br>
<tt>&lt;/xs:schema&gt;</tt><br>
</blockquote>
<br>
Attempt to get using something like:<br>
<br>
<blockquote><tt>Resource res&nbsp; = ...;</tt><br>
<tt>XSDSchema topLevelSchema = (XSDSchema)res.getContents().get(0);</tt><br>
<tt>XSDInclude xsdInclude =
(XSDInclude)topLevelSchema.getContents().get(0);</tt><br>
<tt>String tns =
xsdInclude.getIncorporatedSchema().getTargetNamespace();</tt ><br>
<tt>// tns is set to the top-level tns</tt><br>
</blockquote>
<br>
Thanks in advance,<br>
Steve<br>
</blockquote>
<br>
</body>
</html>

--------------080706070905030606070404--
Re: Determining if an <include>'d schema has a defined target namespace [message #594704 is a reply to message #59082] Thu, 07 April 2005 10:49 Go to previous message
Ed Merks is currently offline Ed Merks
Messages: 25918
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.
--------------080706070905030606070404
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

Steve,

You can access the resolved schema to get that:

String tns = xsdInclude.getResolvedSchema().getTargetNamespace()

Given an XSDSchema, you can also call getOriginalVersion() to determine
the schema from which it was cloned.


Steve Speicher wrote:

> Hi,
>
> I've got an included schema that doesn't have a targetNamespace
> defined. I'd like to determine that (it isn't defined) but the method
> XSDSchema.getTargetNamespace() returns the "incorporated" schema's
> target namespace (since the top-level schema defines a target namespace).
>
> Is it possible to determine this?
>
> Sample schema:
>
> <!-- top-level.xsd -->
> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
> targetNamespace="http://www.ibm.com/samples">
> <xs:include schemaLocation="include.xsd"/>
> </xs:schema>
>
> <!-- include.xsd -->
> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
> <xs:attribute name="dummy" type="xs:string"/>
> </xs:schema>
>
>
> Attempt to get using something like:
>
> Resource res = ...;
> XSDSchema topLevelSchema = (XSDSchema)res.getContents().get(0);
> XSDInclude xsdInclude =
> (XSDInclude)topLevelSchema.getContents().get(0);
> String tns = xsdInclude.getIncorporatedSchema().getTargetNamespace();
> // tns is set to the top-level tns
>
>
> Thanks in advance,
> Steve



--------------080706070905030606070404
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">
Steve,<br>
<br>
You can access the resolved schema to get that:<br>
<blockquote><tt>String tns =
xsdInclude.getResolvedSchema().getTargetNamespace()</tt><br >
</blockquote>
Given an XSDSchema, you can also call getOriginalVersion() to determine
the schema from which it was cloned.<br>
<br>
<br>
Steve Speicher wrote:
<blockquote cite="midd33grh$dob$1@news.eclipse.org" type="cite">
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
<title></title>
Hi,<br>
<br>
I've got an included schema that doesn't have a targetNamespace
defined.&nbsp; I'd like to determine that (it isn't defined) but the method
XSDSchema.getTargetNamespace() returns the "incorporated" schema's
target namespace (since the top-level schema defines a target
namespace).<br>
<br>
Is it possible to determine this?<br>
<br>
Sample schema:<br>
<blockquote><tt>&lt;!-- top-level.xsd --&gt;</tt><br>
<tt>&lt;xs:schema xmlns:xs=<a class="moz-txt-link-rfc2396E"
href="http://www.w3.org/2001/XMLSchema">"http://www.w3.org/2001/XMLSchema"</a>
targetNamespace=<a class="moz-txt-link-rfc2396E"
href="http://www.ibm.com/samples">"http://www.ibm.com/samples"</a>&gt;</tt><br>
<tt>&nbsp; &lt;xs:include schemaLocation="include.xsd"/&gt;</tt><br>
<tt>&lt;/xs:schema&gt;</tt><br>
<br>
<tt>&lt;!-- include.xsd --&gt;</tt><br>
<tt>&lt;xs:schema xmlns:xs=<a class="moz-txt-link-rfc2396E"
href="http://www.w3.org/2001/XMLSchema">"http://www.w3.org/2001/XMLSchema"</a>&gt;</tt><br>
<tt>&nbsp; &lt;xs:attribute name="dummy" type="xs:string"/&gt;</tt><br>
<tt>&lt;/xs:schema&gt;</tt><br>
</blockquote>
<br>
Attempt to get using something like:<br>
<br>
<blockquote><tt>Resource res&nbsp; = ...;</tt><br>
<tt>XSDSchema topLevelSchema = (XSDSchema)res.getContents().get(0);</tt><br>
<tt>XSDInclude xsdInclude =
(XSDInclude)topLevelSchema.getContents().get(0);</tt><br>
<tt>String tns =
xsdInclude.getIncorporatedSchema().getTargetNamespace();</tt ><br>
<tt>// tns is set to the top-level tns</tt><br>
</blockquote>
<br>
Thanks in advance,<br>
Steve<br>
</blockquote>
<br>
</body>
</html>

--------------080706070905030606070404--
Previous Topic:Determining if an <include>'d schema has a defined target namespace
Next Topic:How to get elemnts in a sequence ?
Goto Forum:
  


Current Time: Fri Jul 25 05:14:58 EDT 2014

Powered by FUDForum. Page generated in 0.01893 seconds