Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » XML Schema Definition (XSD) » namespace prefix to URL resolution
namespace prefix to URL resolution [message #25678] Thu, 31 July 2003 16:50 Go to next message
Eclipse UserFriend
Originally posted by: carman.itc.it

Dear All,

I'm trying to obtain the (simple) type definitions of "elements" within
soap encoded arrays. Here's an example of one such array declaration:

<xsd:attribute ref="soapenc:arrayType"
wsdl:arrayType="typens:CustomerReview[]"/>

Here the attribute, "arrayType" is a string, but the SOAP engine
understands that the string really contains objects of type
"typens:CustomerReview" as a single dimensional array. (Ugly way of
encoding your data, I know, but people seem to use this construction!)

My problem is, that when inspecting such an attribute, I want to resolve
the "typens:CustomerReview" (simple) type definition and view its
properties. Before calling the resolveSimpleTypeDefinition() method, I
need to find the URL which the namespace prefix "typens" represents. I had
a look in both the XSD and DOM apis and couldn't find a method to do this.
Does anybody know how to map prefixes to the URLs they represent? I'm sure
it must be really simple.

Thanks a lot,

Mark
Re: namespace prefix to URL resolution [message #25819 is a reply to message #25678] Thu, 31 July 2003 17:13 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: merks.ca.ibm.com

--------------1588619BC5AD3F6387D487AD
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

Mark,

Here's some code that given a complex type that is a soap encoding array type
will return the resolved item type (or null otherwise):

protected Object
getSOAPEncodingArrayItemType(XSDComplexTypeDefinition
xsdComplexTypeDefinition)
{
if
(xsdComplexTypeDefinition.getBaseTypeDefinition().getURI().e quals(SOAP_ENCODING_ARRAY))

{
for (Iterator attributeContents =
xsdComplexTypeDefinition.getAttributeContents().iterator();
attributeContents.hasNext(); )
{
XSDAttributeUse xsdAttributeUse =
(XSDAttributeUse)attributeContents.next();
XSDAttributeDeclaration xsdAttributeDeclaration =
xsdAttributeUse.getAttributeDeclaration();
if (xsdAttributeDeclaration.getURI().equals(SOAP_ENCODING_URI
+ "#" + "arrayType"))
{
Element attributeElement = xsdAttributeUse.getElement();
if (attributeElement != null &&
attributeElement.hasAttributeNS(WSDL_URI, "arrayType"))
{
String arrayType =
attributeElement.getAttributeNS(WSDL_URI, "arrayType");
int index = arrayType.indexOf("[");
if (index != -1)
{
String arrayTypeURI =
XSDConstants.lookupQName(attributeElement, arrayType.substring(0,
index));
XSDTypeDefinition itemTypeDefinition =
xsdAttributeUse.resolveTypeDefinitionURI(arrayTypeURI);
return itemTypeDefinition;
}
}
}
}
}

return null;
}



Mark Carman wrote:

> Dear All,
>
> I'm trying to obtain the (simple) type definitions of "elements" within
> soap encoded arrays. Here's an example of one such array declaration:
>
> <xsd:attribute ref="soapenc:arrayType"
> wsdl:arrayType="typens:CustomerReview[]"/>
>
> Here the attribute, "arrayType" is a string, but the SOAP engine
> understands that the string really contains objects of type
> "typens:CustomerReview" as a single dimensional array. (Ugly way of
> encoding your data, I know, but people seem to use this construction!)
>
> My problem is, that when inspecting such an attribute, I want to resolve
> the "typens:CustomerReview" (simple) type definition and view its
> properties. Before calling the resolveSimpleTypeDefinition() method, I
> need to find the URL which the namespace prefix "typens" represents. I had
> a look in both the XSD and DOM apis and couldn't find a method to do this.
> Does anybody know how to map prefixes to the URLs they represent? I'm sure
> it must be really simple.
>
> Thanks a lot,
>
> Mark

--------------1588619BC5AD3F6387D487AD
Content-Type: text/html; charset=us-ascii
Content-Transfer-Encoding: 7bit

<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
Mark,
<p>Here's some code that given a complex type that is a soap encoding array
type will return the resolved item type (or null otherwise):
<blockquote><tt>protected Object getSOAPEncodingArrayItemType(XSDComplexTypeDefinition
xsdComplexTypeDefinition)</tt>
<br><tt>{</tt>
<br><tt>&nbsp; if (xsdComplexTypeDefinition.getBaseTypeDefinition().getURI().e quals(SOAP_ENCODING_ARRAY)) </tt>
<br><tt>&nbsp; {</tt>
<br><tt>&nbsp;&nbsp;&nbsp; for (Iterator attributeContents = xsdComplexTypeDefinition.getAttributeContents().iterator();
attributeContents.hasNext(); )</tt>
<br><tt>&nbsp;&nbsp;&nbsp; {</tt>
<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; XSDAttributeUse xsdAttributeUse
= (XSDAttributeUse)attributeContents.next();</tt>
<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; XSDAttributeDeclaration xsdAttributeDeclaration
= xsdAttributeUse.getAttributeDeclaration();</tt>
<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (xsdAttributeDeclaration.getURI().equals(SOAP_ENCODING_URI
+ "#" + "arrayType"))</tt>
<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {</tt>
<br><tt> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; Element attributeElement
= xsdAttributeUse.getElement();</tt>
<br><tt> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; if (attributeElement
!= null &amp;&amp; attributeElement.hasAttributeNS(WSDL_URI, "arrayType"))</tt>
<br><tt> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; {</tt>
<br><tt> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; String arrayType
= attributeElement.getAttributeNS(WSDL_URI, "arrayType");</tt>
<br><tt> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; int index
= arrayType.indexOf("[");</tt>
<br><tt> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; if (index
!= -1)</tt>
<br><tt> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {</tt>
<br><tt> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
String arrayTypeURI = XSDConstants.lookupQName(attributeElement, arrayType.substring(0,
index));</tt>
<br><tt> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
XSDTypeDefinition itemTypeDefinition = xsdAttributeUse.resolveTypeDefinitionURI(arrayTypeURI);</tt >
<br><tt> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
return itemTypeDefinition;</tt>
<br><tt> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }</tt>
<br><tt> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; }</tt>
<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</tt>
<br><tt>&nbsp;&nbsp;&nbsp; }</tt>
<br><tt>&nbsp; }</tt><tt></tt>
<p><tt>&nbsp; return null;</tt>
<br><tt>}</tt></blockquote>

<br>&nbsp;
<p>Mark Carman wrote:
<blockquote TYPE=CITE>Dear All,
<p>I'm trying to obtain the (simple) type definitions of "elements" within
<br>soap encoded arrays. Here's an example of one such array declaration:
<p>&lt;xsd:attribute ref="soapenc:arrayType"
<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;
wsdl:arrayType="typens:CustomerReview[]"/>
<p>Here the attribute, "arrayType" is a string, but the SOAP engine
<br>understands that the string really contains objects of type
<br>"typens:CustomerReview" as a single dimensional array. (Ugly way of
<br>encoding your data, I know, but people seem to use this construction!)
<p>My problem is, that when inspecting such an attribute, I want to resolve
<br>the "typens:CustomerReview" (simple) type definition and view its
<br>properties. Before calling the resolveSimpleTypeDefinition() method,
I
<br>need to find the URL which the namespace prefix "typens" represents.
I had
<br>a look in both the XSD and DOM apis and couldn't find a method to do
this.
<br>Does anybody know how to map prefixes to the URLs they represent? I'm
sure
<br>it must be really simple.
<p>Thanks a lot,
<p>Mark</blockquote>
</html>

--------------1588619BC5AD3F6387D487AD--
Re: namespace prefix to URL resolution [message #25900 is a reply to message #25819] Fri, 01 August 2003 07:31 Go to previous message
Eclipse UserFriend
Originally posted by: carman.itc.it

Dear Ed,

thank you very much for your help!

Yours,

Mark



Ed Merks wrote:

> Mark,

> Here's some code that given a complex type that is a soap encoding array type
> will return the resolved item type (or null otherwise):

> protected Object
> getSOAPEncodingArrayItemType(XSDComplexTypeDefinition
> xsdComplexTypeDefinition)
> {
> if
>
(xsdComplexTypeDefinition.getBaseTypeDefinition().getURI().e quals(SOAP_ENCODING_ARRAY))

> {
> for (Iterator attributeContents =
> xsdComplexTypeDefinition.getAttributeContents().iterator();
> attributeContents.hasNext(); )
> {
> XSDAttributeUse xsdAttributeUse =
> (XSDAttributeUse)attributeContents.next();
> XSDAttributeDeclaration xsdAttributeDeclaration =
> xsdAttributeUse.getAttributeDeclaration();
> if (xsdAttributeDeclaration.getURI().equals(SOAP_ENCODING_URI
> + "#" + "arrayType"))
> {
> Element attributeElement = xsdAttributeUse.getElement();
> if (attributeElement != null &&
> attributeElement.hasAttributeNS(WSDL_URI, "arrayType"))
> {
> String arrayType =
> attributeElement.getAttributeNS(WSDL_URI, "arrayType");
> int index = arrayType.indexOf("[");
> if (index != -1)
> {
> String arrayTypeURI =
> XSDConstants.lookupQName(attributeElement, arrayType.substring(0,
> index));
> XSDTypeDefinition itemTypeDefinition =
> xsdAttributeUse.resolveTypeDefinitionURI(arrayTypeURI);
> return itemTypeDefinition;
> }
> }
> }
> }
> }

> return null;
> }



> Mark Carman wrote:

> > Dear All,
> >
> > I'm trying to obtain the (simple) type definitions of "elements" within
> > soap encoded arrays. Here's an example of one such array declaration:
> >
> > <xsd:attribute ref="soapenc:arrayType"
> > wsdl:arrayType="typens:CustomerReview[]"/>
> >
> > Here the attribute, "arrayType" is a string, but the SOAP engine
> > understands that the string really contains objects of type
> > "typens:CustomerReview" as a single dimensional array. (Ugly way of
> > encoding your data, I know, but people seem to use this construction!)
> >
> > My problem is, that when inspecting such an attribute, I want to resolve
> > the "typens:CustomerReview" (simple) type definition and view its
> > properties. Before calling the resolveSimpleTypeDefinition() method, I
> > need to find the URL which the namespace prefix "typens" represents. I had
> > a look in both the XSD and DOM apis and couldn't find a method to do this.
> > Does anybody know how to map prefixes to the URLs they represent? I'm sure
> > it must be really simple.
> >
> > Thanks a lot,
> >
> > Mark
Re: namespace prefix to URL resolution [message #575298 is a reply to message #25678] Thu, 31 July 2003 17:13 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 26289
Registered: July 2009
Senior Member
--------------1588619BC5AD3F6387D487AD
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

Mark,

Here's some code that given a complex type that is a soap encoding array type
will return the resolved item type (or null otherwise):

protected Object
getSOAPEncodingArrayItemType(XSDComplexTypeDefinition
xsdComplexTypeDefinition)
{
if
(xsdComplexTypeDefinition.getBaseTypeDefinition().getURI().e quals(SOAP_ENCODING_ARRAY))

{
for (Iterator attributeContents =
xsdComplexTypeDefinition.getAttributeContents().iterator();
attributeContents.hasNext(); )
{
XSDAttributeUse xsdAttributeUse =
(XSDAttributeUse)attributeContents.next();
XSDAttributeDeclaration xsdAttributeDeclaration =
xsdAttributeUse.getAttributeDeclaration();
if (xsdAttributeDeclaration.getURI().equals(SOAP_ENCODING_URI
+ "#" + "arrayType"))
{
Element attributeElement = xsdAttributeUse.getElement();
if (attributeElement != null &&
attributeElement.hasAttributeNS(WSDL_URI, "arrayType"))
{
String arrayType =
attributeElement.getAttributeNS(WSDL_URI, "arrayType");
int index = arrayType.indexOf("[");
if (index != -1)
{
String arrayTypeURI =
XSDConstants.lookupQName(attributeElement, arrayType.substring(0,
index));
XSDTypeDefinition itemTypeDefinition =
xsdAttributeUse.resolveTypeDefinitionURI(arrayTypeURI);
return itemTypeDefinition;
}
}
}
}
}

return null;
}



Mark Carman wrote:

> Dear All,
>
> I'm trying to obtain the (simple) type definitions of "elements" within
> soap encoded arrays. Here's an example of one such array declaration:
>
> <xsd:attribute ref="soapenc:arrayType"
> wsdl:arrayType="typens:CustomerReview[]"/>
>
> Here the attribute, "arrayType" is a string, but the SOAP engine
> understands that the string really contains objects of type
> "typens:CustomerReview" as a single dimensional array. (Ugly way of
> encoding your data, I know, but people seem to use this construction!)
>
> My problem is, that when inspecting such an attribute, I want to resolve
> the "typens:CustomerReview" (simple) type definition and view its
> properties. Before calling the resolveSimpleTypeDefinition() method, I
> need to find the URL which the namespace prefix "typens" represents. I had
> a look in both the XSD and DOM apis and couldn't find a method to do this.
> Does anybody know how to map prefixes to the URLs they represent? I'm sure
> it must be really simple.
>
> Thanks a lot,
>
> Mark

--------------1588619BC5AD3F6387D487AD
Content-Type: text/html; charset=us-ascii
Content-Transfer-Encoding: 7bit

<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
Mark,
<p>Here's some code that given a complex type that is a soap encoding array
type will return the resolved item type (or null otherwise):
<blockquote><tt>protected Object getSOAPEncodingArrayItemType(XSDComplexTypeDefinition
xsdComplexTypeDefinition)</tt>
<br><tt>{</tt>
<br><tt>&nbsp; if (xsdComplexTypeDefinition.getBaseTypeDefinition().getURI().e quals(SOAP_ENCODING_ARRAY)) </tt>
<br><tt>&nbsp; {</tt>
<br><tt>&nbsp;&nbsp;&nbsp; for (Iterator attributeContents = xsdComplexTypeDefinition.getAttributeContents().iterator();
attributeContents.hasNext(); )</tt>
<br><tt>&nbsp;&nbsp;&nbsp; {</tt>
<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; XSDAttributeUse xsdAttributeUse
= (XSDAttributeUse)attributeContents.next();</tt>
<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; XSDAttributeDeclaration xsdAttributeDeclaration
= xsdAttributeUse.getAttributeDeclaration();</tt>
<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (xsdAttributeDeclaration.getURI().equals(SOAP_ENCODING_URI
+ "#" + "arrayType"))</tt>
<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {</tt>
<br><tt> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; Element attributeElement
= xsdAttributeUse.getElement();</tt>
<br><tt> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; if (attributeElement
!= null &amp;&amp; attributeElement.hasAttributeNS(WSDL_URI, "arrayType"))</tt>
<br><tt> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; {</tt>
<br><tt> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; String arrayType
= attributeElement.getAttributeNS(WSDL_URI, "arrayType");</tt>
<br><tt> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; int index
= arrayType.indexOf("[");</tt>
<br><tt> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; if (index
!= -1)</tt>
<br><tt> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {</tt>
<br><tt> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
String arrayTypeURI = XSDConstants.lookupQName(attributeElement, arrayType.substring(0,
index));</tt>
<br><tt> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
XSDTypeDefinition itemTypeDefinition = xsdAttributeUse.resolveTypeDefinitionURI(arrayTypeURI);</tt >
<br><tt> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
return itemTypeDefinition;</tt>
<br><tt> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }</tt>
<br><tt> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; }</tt>
<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</tt>
<br><tt>&nbsp;&nbsp;&nbsp; }</tt>
<br><tt>&nbsp; }</tt><tt></tt>
<p><tt>&nbsp; return null;</tt>
<br><tt>}</tt></blockquote>

<br>&nbsp;
<p>Mark Carman wrote:
<blockquote TYPE=CITE>Dear All,
<p>I'm trying to obtain the (simple) type definitions of "elements" within
<br>soap encoded arrays. Here's an example of one such array declaration:
<p>&lt;xsd:attribute ref="soapenc:arrayType"
<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;
wsdl:arrayType="typens:CustomerReview[]"/>
<p>Here the attribute, "arrayType" is a string, but the SOAP engine
<br>understands that the string really contains objects of type
<br>"typens:CustomerReview" as a single dimensional array. (Ugly way of
<br>encoding your data, I know, but people seem to use this construction!)
<p>My problem is, that when inspecting such an attribute, I want to resolve
<br>the "typens:CustomerReview" (simple) type definition and view its
<br>properties. Before calling the resolveSimpleTypeDefinition() method,
I
<br>need to find the URL which the namespace prefix "typens" represents.
I had
<br>a look in both the XSD and DOM apis and couldn't find a method to do
this.
<br>Does anybody know how to map prefixes to the URLs they represent? I'm
sure
<br>it must be really simple.
<p>Thanks a lot,
<p>Mark</blockquote>
</html>

--------------1588619BC5AD3F6387D487AD--
Re: namespace prefix to URL resolution [message #575410 is a reply to message #25819] Fri, 01 August 2003 07:31 Go to previous message
Eclipse UserFriend
Originally posted by: carman.itc.it

Dear Ed,

thank you very much for your help!

Yours,

Mark



Ed Merks wrote:

> Mark,

> Here's some code that given a complex type that is a soap encoding array type
> will return the resolved item type (or null otherwise):

> protected Object
> getSOAPEncodingArrayItemType(XSDComplexTypeDefinition
> xsdComplexTypeDefinition)
> {
> if
>
(xsdComplexTypeDefinition.getBaseTypeDefinition().getURI().e quals(SOAP_ENCODING_ARRAY))

> {
> for (Iterator attributeContents =
> xsdComplexTypeDefinition.getAttributeContents().iterator();
> attributeContents.hasNext(); )
> {
> XSDAttributeUse xsdAttributeUse =
> (XSDAttributeUse)attributeContents.next();
> XSDAttributeDeclaration xsdAttributeDeclaration =
> xsdAttributeUse.getAttributeDeclaration();
> if (xsdAttributeDeclaration.getURI().equals(SOAP_ENCODING_URI
> + "#" + "arrayType"))
> {
> Element attributeElement = xsdAttributeUse.getElement();
> if (attributeElement != null &&
> attributeElement.hasAttributeNS(WSDL_URI, "arrayType"))
> {
> String arrayType =
> attributeElement.getAttributeNS(WSDL_URI, "arrayType");
> int index = arrayType.indexOf("[");
> if (index != -1)
> {
> String arrayTypeURI =
> XSDConstants.lookupQName(attributeElement, arrayType.substring(0,
> index));
> XSDTypeDefinition itemTypeDefinition =
> xsdAttributeUse.resolveTypeDefinitionURI(arrayTypeURI);
> return itemTypeDefinition;
> }
> }
> }
> }
> }

> return null;
> }



> Mark Carman wrote:

> > Dear All,
> >
> > I'm trying to obtain the (simple) type definitions of "elements" within
> > soap encoded arrays. Here's an example of one such array declaration:
> >
> > <xsd:attribute ref="soapenc:arrayType"
> > wsdl:arrayType="typens:CustomerReview[]"/>
> >
> > Here the attribute, "arrayType" is a string, but the SOAP engine
> > understands that the string really contains objects of type
> > "typens:CustomerReview" as a single dimensional array. (Ugly way of
> > encoding your data, I know, but people seem to use this construction!)
> >
> > My problem is, that when inspecting such an attribute, I want to resolve
> > the "typens:CustomerReview" (simple) type definition and view its
> > properties. Before calling the resolveSimpleTypeDefinition() method, I
> > need to find the URL which the namespace prefix "typens" represents. I had
> > a look in both the XSD and DOM apis and couldn't find a method to do this.
> > Does anybody know how to map prefixes to the URLs they represent? I'm sure
> > it must be really simple.
> >
> > Thanks a lot,
> >
> > Mark
Previous Topic:Generating Java Classes from XSD
Next Topic:XPath pattern error
Goto Forum:
  


Current Time: Mon Dec 22 12:02:58 GMT 2014

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

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