You are viewing a plain text version of this content. The canonical link for it is here.
Posted to wsrf-dev@ws.apache.org by ip...@apache.org on 2005/03/15 01:23:38 UTC
svn commit: r157488 -
incubator/apollo/trunk/src/java/org/apache/ws/util/WsrfWsdlUtils.java
Author: ips
Date: Mon Mar 14 16:23:37 2005
New Revision: 157488
URL: http://svn.apache.org/viewcvs?view=rev&rev=157488
Log:
fixed bug in handling of a RP doc xsd elem that references an external complexType
Modified:
incubator/apollo/trunk/src/java/org/apache/ws/util/WsrfWsdlUtils.java
Modified: incubator/apollo/trunk/src/java/org/apache/ws/util/WsrfWsdlUtils.java
URL: http://svn.apache.org/viewcvs/incubator/apollo/trunk/src/java/org/apache/ws/util/WsrfWsdlUtils.java?view=diff&r1=157487&r2=157488
==============================================================================
--- incubator/apollo/trunk/src/java/org/apache/ws/util/WsrfWsdlUtils.java (original)
+++ incubator/apollo/trunk/src/java/org/apache/ws/util/WsrfWsdlUtils.java Mon Mar 14 16:23:37 2005
@@ -121,13 +121,18 @@
if ( rpDocXsdElem == null )
{
throw new InvalidWsrfWsdlException(
- "Unable to locate the ResourceProperties Document Element with QName " + rpDocElemName );
+ "Unable to locate the ResourceProperties document element with QName " + rpDocElemName );
}
- String type = rpDocXsdElem.getElement().getAttribute( "type" );
+ QName type = getQualifiedAttribute( rpDocXsdElem, "type" );
Element rpDocTypeElem;
- if ( !"".equals( type ) )
+ if ( type != null )
{
- rpDocTypeElem = getComplexTypeByName( rpDocXsdElem.getSchemaElement(), type );
+ if ( ! type.getNamespaceURI().equals( rpDocXsdElem.getSchemaElement().getAttribute( "targetNamespace" ) ) )
+ {
+ throw new InvalidWsrfWsdlException(
+ "This tool currently does not support referencing a ResourceProperties complexType that is not in the current schema's targetNamespace." );
+ }
+ rpDocTypeElem = getComplexTypeByName( rpDocXsdElem.getSchemaElement(), type.getLocalPart() );
}
else
{
@@ -163,7 +168,11 @@
for ( int j = 0; j < propElems.getLength(); j++ )
{
Element propElem = (Element) propElems.item( j );
- QName propName = getElementRefName( propElem, rpDocXsdElem.getSchemaElement() );
+ QName propName = getQualifiedAttribute( new XsdElement( propElem, rpDocXsdElem.getSchemaElement() ), "ref" );
+ if ( propName == null )
+ {
+ throw new InvalidWsrfWsdlException( "All element defs within the resource property document def must have a 'ref' attribute that points at a global element def." );
+ }
propNames.add( propName );
}
return (QName[]) propNames.toArray( new QName[0] );
@@ -201,31 +210,49 @@
return xsdElementElem;
}
- private static QName getElementRefName( Element propElem, Element schemaElem )
+ private static QName getQualifiedAttribute( XsdElement xsdElem, String attribName )
throws InvalidWsrfWsdlException
{
- String ref = propElem.getAttribute( "ref" );
- if ( "".equals( ref ) )
+ String value = xsdElem.getElement().getAttribute( attribName );
+ if ( "".equals( value ) )
{
- throw new InvalidWsrfWsdlException(
- "All element defs within the resource property document def must have a 'ref' attribute that points at a global element def." );
+ return null;
}
- StringTokenizer tokenizer = new StringTokenizer( ref, ":" );
- if ( tokenizer.countTokens() != 2 )
+ PrefixResolver prefixResolver = new PrefixResolverDefault( xsdElem.getSchemaElement() );
+ QName propName = null;
+ try
+ {
+ propName = toQName( value, prefixResolver );
+ }
+ catch ( PrefixResolutionException pre )
+ {
+ throw new InvalidWsrfWsdlException( "Unable to resolve prefix '" + pre.getPrefix() + "' in xsd:element '" + attribName + "' attribute value." );
+ }
+ catch ( InvalidValueException ive )
{
throw new InvalidWsrfWsdlException( "Value for xsd:element 'ref' attribute must be qualified via a namespace prefix." );
}
- String propPrefix = tokenizer.nextToken();
- String propLocalName = tokenizer.nextToken();
+ return propName;
+ }
+
+ private static QName toQName( String value, PrefixResolver prefixResolver ) throws InvalidValueException,
+ PrefixResolutionException
+ {
+ StringTokenizer tokenizer = new StringTokenizer( value, ":" );
+ if ( tokenizer.countTokens() != 2 )
+ {
+ throw new InvalidValueException();
+ }
+ String prefix = tokenizer.nextToken();
+ String localName = tokenizer.nextToken();
// TODO: write our own prefix resolver to eliminate dep on Xalan
- PrefixResolver prefixResolver = new PrefixResolverDefault( schemaElem );
- String propNamespace = prefixResolver.getNamespaceForPrefix( propPrefix );
- if ( propNamespace == null )
+ String namespace = prefixResolver.getNamespaceForPrefix( prefix );
+ if ( namespace == null )
{
- throw new InvalidWsrfWsdlException( "Unable to resolve prefix '" + propPrefix + "' in xsd:element 'ref' attribute value." );
+ throw new PrefixResolutionException( prefix );
}
- QName propName = new QName( propNamespace, propLocalName, propPrefix );
- return propName;
+ QName qName = new QName( namespace, localName, prefix );
+ return qName;
}
private static String[] findImportsAndIncludes( Element schemaElem, String namespaceURI )
@@ -389,6 +416,26 @@
{
return m_schemaElem;
}
+ }
+
+ private static class PrefixResolutionException extends Exception
+ {
+ private String m_prefix;
+
+ public PrefixResolutionException( String prefix )
+ {
+ super();
+ m_prefix = prefix;
+ }
+
+ public String getPrefix()
+ {
+ return m_prefix;
+ }
+ }
+
+ private static class InvalidValueException extends Exception
+ {
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: apollo-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: apollo-dev-help@ws.apache.org