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 #594696] Thu, 07 April 2005 14:37
Steve Speicher is currently offline Steve Speicher
Messages: 85
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--
Previous Topic:Problems with <redefine>
Next Topic:Determining if an <include>'d schema has a defined target namespace
Goto Forum:
  


Current Time: Sat Oct 25 01:48:50 GMT 2014

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

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