Home » Archived » XML Schema Definition (XSD) » namespace prefix to URL resolution
namespace prefix to URL resolution [message #25678] |
Thu, 31 July 2003 12:50  |
Eclipse User |
|
|
|
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 13:13   |
Eclipse User |
|
|
|
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> if (xsdComplexTypeDefinition.getBaseTypeDefinition().getURI().e quals(SOAP_ENCODING_ARRAY)) </tt>
<br><tt> {</tt>
<br><tt> for (Iterator attributeContents = xsdComplexTypeDefinition.getAttributeContents().iterator();
attributeContents.hasNext(); )</tt>
<br><tt> {</tt>
<br><tt> XSDAttributeUse xsdAttributeUse
= (XSDAttributeUse)attributeContents.next();</tt>
<br><tt> XSDAttributeDeclaration xsdAttributeDeclaration
= xsdAttributeUse.getAttributeDeclaration();</tt>
<br><tt> if (xsdAttributeDeclaration.getURI().equals(SOAP_ENCODING_URI
+ "#" + "arrayType"))</tt>
<br><tt> {</tt>
<br><tt> Element attributeElement
= xsdAttributeUse.getElement();</tt>
<br><tt> if (attributeElement
!= null && attributeElement.hasAttributeNS(WSDL_URI, "arrayType"))</tt>
<br><tt> {</tt>
<br><tt> String arrayType
= attributeElement.getAttributeNS(WSDL_URI, "arrayType");</tt>
<br><tt> int index
= arrayType.indexOf("[");</tt>
<br><tt> if (index
!= -1)</tt>
<br><tt> {</tt>
<br><tt>
String arrayTypeURI = XSDConstants.lookupQName(attributeElement, arrayType.substring(0,
index));</tt>
<br><tt>
XSDTypeDefinition itemTypeDefinition = xsdAttributeUse.resolveTypeDefinitionURI(arrayTypeURI);</tt >
<br><tt>
return itemTypeDefinition;</tt>
<br><tt> }</tt>
<br><tt> }</tt>
<br><tt> }</tt>
<br><tt> }</tt>
<br><tt> }</tt><tt></tt>
<p><tt> return null;</tt>
<br><tt>}</tt></blockquote>
<br>
<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><xsd:attribute ref="soapenc:arrayType"
<br>
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 03:31  |
Eclipse User |
|
|
|
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 13:13  |
Eclipse User |
|
|
|
--------------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> if (xsdComplexTypeDefinition.getBaseTypeDefinition().getURI().e quals(SOAP_ENCODING_ARRAY)) </tt>
<br><tt> {</tt>
<br><tt> for (Iterator attributeContents = xsdComplexTypeDefinition.getAttributeContents().iterator();
attributeContents.hasNext(); )</tt>
<br><tt> {</tt>
<br><tt> XSDAttributeUse xsdAttributeUse
= (XSDAttributeUse)attributeContents.next();</tt>
<br><tt> XSDAttributeDeclaration xsdAttributeDeclaration
= xsdAttributeUse.getAttributeDeclaration();</tt>
<br><tt> if (xsdAttributeDeclaration.getURI().equals(SOAP_ENCODING_URI
+ "#" + "arrayType"))</tt>
<br><tt> {</tt>
<br><tt> Element attributeElement
= xsdAttributeUse.getElement();</tt>
<br><tt> if (attributeElement
!= null && attributeElement.hasAttributeNS(WSDL_URI, "arrayType"))</tt>
<br><tt> {</tt>
<br><tt> String arrayType
= attributeElement.getAttributeNS(WSDL_URI, "arrayType");</tt>
<br><tt> int index
= arrayType.indexOf("[");</tt>
<br><tt> if (index
!= -1)</tt>
<br><tt> {</tt>
<br><tt>
String arrayTypeURI = XSDConstants.lookupQName(attributeElement, arrayType.substring(0,
index));</tt>
<br><tt>
XSDTypeDefinition itemTypeDefinition = xsdAttributeUse.resolveTypeDefinitionURI(arrayTypeURI);</tt >
<br><tt>
return itemTypeDefinition;</tt>
<br><tt> }</tt>
<br><tt> }</tt>
<br><tt> }</tt>
<br><tt> }</tt>
<br><tt> }</tt><tt></tt>
<p><tt> return null;</tt>
<br><tt>}</tt></blockquote>
<br>
<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><xsd:attribute ref="soapenc:arrayType"
<br>
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 03:31  |
Eclipse User |
|
|
|
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
|
|
|
Goto Forum:
Current Time: Sun May 11 15:57:48 EDT 2025
Powered by FUDForum. Page generated in 0.03262 seconds
|