Java Code Examples for org.dom4j.Namespace.NO_NAMESPACE

The following are Jave code examples for showing how to use NO_NAMESPACE of the org.dom4j.Namespace class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: joai-project   File: ComplexType.java   Source Code and License Vote up 6 votes
/**
 *  String representation of the ComplexType object
 *
 * @return    a String representation of the ComplexType object
 */
public String toString() {
	String s = "ComplexType: " + getName();
	String nl = "\n\t";
	s += nl + "type: " + getType();
	s += nl + "location: " + getLocation();
	s += nl + "contentmodel: " + getContentModel();
	if (getNamespace() != Namespace.NO_NAMESPACE)
		s += nl + "namespace: " + getNamespace().getPrefix() + ": " + getNamespace().getURI();
	else
		s += nl + "namespace: null";
	//		s += nl + "modelGroup: " + modelGroup;
	//		s += nl + "there are " + getChildren().size() + " content elements";
	/*
		 *  if (modelGroup == null)
		 *  s += "\n" + element.asXML();
		 */
	s += nl + "schemaNamespace: " + this.getSchemaReader().getNamespaces().getSchemaNamespace().getPrefix();
	s += Dom4jUtils.prettyPrint(getElement());
	return s;
}
 
Example 2
Project: joai-project   File: SimpleType.java   Source Code and License Vote up 6 votes
/**
 *  Description of the Method
 *
 *@return    Description of the Return Value
 */
public String toString() {
	String s = "SimpleType: " + getName();
	s += "\n\t location: " + getLocation();
	if (isEnumeration()) {
		s += "\n\tEnumeration";
		for (Iterator i = getSimpleEnumerationValues().iterator(); i.hasNext(); ) {
			s += "\n\t\t" + (String) i.next();
		}
	}
	else if (isUnion()) {
		s += "\n\tUnion (" + getUnionMemberTypesAsString() + ")";
	}
	else {
		s += getElement().asXML();
	}
	if (getNamespace() != Namespace.NO_NAMESPACE)
		s += "\n\tnamespace: " + getNamespace().getPrefix() + ": " + getNamespace().getURI();
	else
		s += "\n\tnamespace: null";
	return s;
}
 
Example 3
Project: joai-project   File: ReaderStack.java   Source Code and License Vote up 6 votes
/**
* Search the stack (moving from local to more global SchemaReaders) for the namespace
* belonging to the given prefix.
*/
public Namespace getNamespaceForPrefix (String prefix) {
	Namespace ns = Namespace.NO_NAMESPACE;
	prtln ("\n\tReaderStack.getNamespace() looking for prefix: " + prefix);
	for (int i=0; i < size(); i++) {
		SchemaReader sr = getItemAt(i);
		prtln ("\t\t " + sr.getLocation());
		NamespaceRegistry namespaceContext = sr.getNamespaces();
		ns = namespaceContext.getNSforPrefix(prefix);
		if (!ns.getPrefix().equals("")) {
			prtln ("\t\t\t ... found namespace -- " + ns.getPrefix() + ": " + ns.getURI());
			break;
		}
	}
	return ns;
}
 
Example 4
Project: joai-project   File: SchemaReader.java   Source Code and License Vote up 6 votes
/**
* Return globalDef from the globalDefMap after resolving the given typeName into a baseName and namespace. 
Returns null if namespace cannot be determined.

NOTE: this can be refactored to use getInstanceQualifiedName (returned prefix must be resolved into a namespace
before the call to globalDefMap.getValue (baseName, namespace)
*/
public GlobalDef getGlobalDef (String typeName) {
	// prtln ("getGlobalDef with " + typeName);
	Namespace namespace = targetNamespace;
	String prefix = null;
	String baseName = typeName;
	if (NamespaceRegistry.isQualified(typeName)) {
		baseName = NamespaceRegistry.stripNamespacePrefix(typeName);
		prefix = NamespaceRegistry.getNamespacePrefix(typeName);
		namespace = getNamespaces().getNSforPrefix(prefix);
		if (namespace == Namespace.NO_NAMESPACE) {
			prtln ("\nWARNING: getGlobalDef can't find namespace for \"" + prefix + "\"");
			prtln (this.namespaces.toString());
			return null;
		}
	}
	return globalDefMap.getValue (baseName, namespace.getURI());
}
 
Example 5
Project: joai-project   File: ModelGroup.java   Source Code and License Vote up 6 votes
/**
 *  String representation of the ModelGroup object
 *
 * @return    a String representation of the ModelGroup object
 */
public String toString() {
	String s = "ModelGroup: " + getName();
	String nl = "\n\t";
	s += nl + "type: " + getType();
	s += nl + "location: " + getLocation();
	s += nl + "contentmodel: " + getContentModel();
	if (getNamespace() != Namespace.NO_NAMESPACE)
		s += nl + "namespace: " + getNamespace().getPrefix() + ": " + getNamespace().getURI();
	else
		s += nl + "namespace: null";
	//		s += nl + "modelGroup: " + modelGroup;
	//		s += nl + "there are " + getChildren().size() + " content elements";
	/*
		 *  if (modelGroup == null)
		 *  s += "\n" + element.asXML();
		 */
	// s += Dom4jUtils.prettyPrint (getElement());
	return s;
}
 
Example 6
Project: dls-repository-stack   File: ComplexType.java   Source Code and License Vote up 6 votes
/**
 *  String representation of the ComplexType object
 *
 * @return    a String representation of the ComplexType object
 */
public String toString() {
	String s = "ComplexType: " + getName();
	String nl = "\n\t";
	s += nl + "type: " + getType();
	s += nl + "location: " + getLocation();
	s += nl + "contentmodel: " + getContentModel();
	if (getNamespace() != Namespace.NO_NAMESPACE)
		s += nl + "namespace: " + getNamespace().getPrefix() + ": " + getNamespace().getURI();
	else
		s += nl + "namespace: null";
	//		s += nl + "modelGroup: " + modelGroup;
	//		s += nl + "there are " + getChildren().size() + " content elements";
	/*
		 *  if (modelGroup == null)
		 *  s += "\n" + element.asXML();
		 */
	s += nl + "schemaNamespace: " + this.getSchemaReader().getNamespaces().getSchemaNamespace().getPrefix();
	s += Dom4jUtils.prettyPrint(getElement());
	return s;
}
 
Example 7
Project: dls-repository-stack   File: SimpleType.java   Source Code and License Vote up 6 votes
/**
 *  Description of the Method
 *
 *@return    Description of the Return Value
 */
public String toString() {
	String s = "SimpleType: " + getName();
	s += "\n\t location: " + getLocation();
	if (isEnumeration()) {
		s += "\n\tEnumeration";
		for (Iterator i = getSimpleEnumerationValues().iterator(); i.hasNext(); ) {
			s += "\n\t\t" + (String) i.next();
		}
	}
	else if (isUnion()) {
		s += "\n\tUnion (" + getUnionMemberTypesAsString() + ")";
	}
	else {
		s += getElement().asXML();
	}
	if (getNamespace() != Namespace.NO_NAMESPACE)
		s += "\n\tnamespace: " + getNamespace().getPrefix() + ": " + getNamespace().getURI();
	else
		s += "\n\tnamespace: null";
	return s;
}
 
Example 8
Project: dls-repository-stack   File: ReaderStack.java   Source Code and License Vote up 6 votes
/**
* Search the stack (moving from local to more global SchemaReaders) for the namespace
* belonging to the given prefix.
*/
public Namespace getNamespaceForPrefix (String prefix) {
	Namespace ns = Namespace.NO_NAMESPACE;
	prtln ("\n\tReaderStack.getNamespace() looking for prefix: " + prefix);
	for (int i=0; i < size(); i++) {
		SchemaReader sr = getItemAt(i);
		prtln ("\t\t " + sr.getLocation());
		NamespaceRegistry namespaceContext = sr.getNamespaces();
		ns = namespaceContext.getNSforPrefix(prefix);
		if (!ns.getPrefix().equals("")) {
			prtln ("\t\t\t ... found namespace -- " + ns.getPrefix() + ": " + ns.getURI());
			break;
		}
	}
	return ns;
}
 
Example 9
Project: dls-repository-stack   File: SchemaReader.java   Source Code and License Vote up 6 votes
/**
 *  Return globalDef from the globalDefMap after resolving the given typeName
 *  into a baseName and namespace. Returns null if namespace cannot be
 *  determined. NOTE: this can be refactored to use getInstanceQualifiedName
 *  (returned prefix must be resolved into a namespace before the call to
 *  globalDefMap.getValue (baseName, namespace)
 *
 * @param  typeName  typeName identifying the globalDef to find
 * @return           The globalDef value
 */
public GlobalDef getGlobalDef(String typeName) {
	// prtln ("getGlobalDef with " + typeName);
	Namespace namespace = targetNamespace;
	String prefix = null;
	String baseName = typeName;
	if (NamespaceRegistry.isQualified(typeName)) {
		baseName = NamespaceRegistry.stripNamespacePrefix(typeName);
		prefix = NamespaceRegistry.getNamespacePrefix(typeName);
		namespace = getNamespaces().getNSforPrefix(prefix);
		if (namespace == Namespace.NO_NAMESPACE) {
			prtln("\nWARNING: getGlobalDef can't find namespace for \"" + prefix + "\"");
			prtln(this.namespaces.toString());
			return null;
		}
	}
	return globalDefMap.getValue(baseName, namespace.getURI());
}
 
Example 10
Project: dls-repository-stack   File: ModelGroup.java   Source Code and License Vote up 6 votes
/**
 *  String representation of the ModelGroup object
 *
 * @return    a String representation of the ModelGroup object
 */
public String toString() {
	String s = "ModelGroup: " + getName();
	String nl = "\n\t";
	s += nl + "type: " + getType();
	s += nl + "location: " + getLocation();
	s += nl + "contentmodel: " + getContentModel();
	if (getNamespace() != Namespace.NO_NAMESPACE)
		s += nl + "namespace: " + getNamespace().getPrefix() + ": " + getNamespace().getURI();
	else
		s += nl + "namespace: null";
	//		s += nl + "modelGroup: " + modelGroup;
	//		s += nl + "there are " + getChildren().size() + " content elements";
	/*
		 *  if (modelGroup == null)
		 *  s += "\n" + element.asXML();
		 */
	// s += Dom4jUtils.prettyPrint (getElement());
	return s;
}
 
Example 11
Project: joai-project   File: ReaderStack.java   Source Code and License Vote up 5 votes
/**
* Traverse the stack to find a SchemaReader that defines a namespace for the given prefix. Return null if
a reader is not found.
*/
public SchemaReader getReaderForPrefix (String prefix) {
	SchemaReader sr = null;
	prtln ("\tReaderStack.getReaderForPrefix() looking for prefix: " + prefix);
	for (int i=0; i < size(); i++) {
		sr = getItemAt(i);
		prtln ("\t\t " + sr.getLocation());
		Namespace ns = sr.getNamespaces().getNSforPrefix(prefix);
		if (ns != Namespace.NO_NAMESPACE) {
			prtln ("\t\t\t ... found reader at -- " + sr.getLocation().toString());
			break;
		}
	}
	return sr;
}
 
Example 12
Project: joai-project   File: ReaderStack.java   Source Code and License Vote up 5 votes
public GlobalDef getGlobalDef (String typeName) {
		prtln ("\ngetGlobalDef() typeName: " + typeName);
		prtln ("\n---------" + toString() + "\n-----------");
		SchemaReader schemaReader = getTos();
		Namespace namespace = schemaReader.getNamespaces().getTargetNamespace();
		String prefix = null;
		String baseName = typeName;
		boolean isMultiNamespace = globalDefMap.getNamespaces().isMultiNamespace();
		prtln ("\t isMultiNamespace: " + isMultiNamespace);
		if (NamespaceRegistry.isQualified(typeName)) {
			baseName = NamespaceRegistry.stripNamespacePrefix(typeName);
			prefix = NamespaceRegistry.getNamespacePrefix(typeName);
			if (prefix == null) prefix="";
			namespace = getNamespaceForPrefix(prefix);
			if (namespace == Namespace.NO_NAMESPACE) {
				prtln ("\t WARNING: namespace not found for \"" + typeName + "\"");
				return null;
			}
/* 			if (namespace == namespaces.getSchemaNamespace()) {
				// return null;
				prtln ("\t\t\t creating builtInType: " + NamespaceRegistry.makeQualifiedName(prefix, typeName));
				return new BuiltInType (NamespaceRegistry.makeQualifiedName(prefix, typeName));
			} */
		}
		// experimental 3/29/2007 - if there is a default Namespace, look in it for 
		
		else {
			prtln ("\t typeName is NOT qualified ... ");
			
			// try to use default name space, then use target ...
			Namespace defaultNamespace = schemaReader.getNamespaces().getDefaultNamespace();
			prtln ("\t\t default namespace is " + NamespaceRegistry.nsToString(namespace));
			if (defaultNamespace != Namespace.NO_NAMESPACE)
				namespace = defaultNamespace;
			
			prtln ("\t\t target namespace is " + NamespaceRegistry.nsToString(namespace));
		}
		return globalDefMap.getValue (baseName, namespace);
	}
 
Example 13
Project: joai-project   File: NamespaceRegistry.java   Source Code and License Vote up 5 votes
/**
 *  Gets the prefix corresponding to the provided uri after finding that uri's
 *  namespace.
 *
 * @param  uri  NOT YET DOCUMENTED
 * @return      The prefixforUri value
 */
public String getPrefixforUri(String uri) {
	Namespace ns = getNSforUri(uri);
	if (ns == Namespace.NO_NAMESPACE) {
		// prtln ("WARNING: getPrefixforUri() did not find namespace not found for " + uri);
	}
	return ns.getPrefix();
}
 
Example 14
Project: joai-project   File: SchemaReader.java   Source Code and License Vote up 5 votes
public String getInstanceQualifiedName (String name) {
	// prtln ("getInstanceQualifiedName() with " + name);
	Namespace namespace = targetNamespace;
	String prefix = null;
	String baseName = name;
	if (NamespaceRegistry.isQualified(name)) {
		baseName = NamespaceRegistry.stripNamespacePrefix(name);
		prefix = NamespaceRegistry.getNamespacePrefix(name);
		namespace = getNamespaces().getNSforPrefix(prefix);
		if (namespace == Namespace.NO_NAMESPACE) {
			prtln ("\nWARNING: getInstanceQualifiedName can't find namespace for \"" + prefix + "\"");
			prtln ("name: " + name);
			prtln ("schemaReader.source: " + this.source);
			prtln (this.namespaces.toString());
			return null;
		}
	}
		
	NamespaceRegistry instanceNamespaces = this.getInstanceNamespaces();
	Namespace instanceNS = instanceNamespaces.getNSforUri(namespace.getURI());
	
	if (instanceNS.getPrefix().equals("")) {
		// if there is a namedDefaultNamespace at the instanceLevel, use it instead ...
		if (instanceNamespaces.getNamedDefaultNamespace() != Namespace.NO_NAMESPACE &&
			instanceNamespaces.isMultiNamespace()) {
			instanceNS = this.getInstanceNamespaces().getNamedDefaultNamespace();
		}
	}
	
	return NamespaceRegistry.makeQualifiedName(instanceNS, baseName);
}
 
Example 15
Project: joai-project   File: GlobalDeclaration.java   Source Code and License Vote up 5 votes
/**
 *  NOT YET DOCUMENTED
 *
 * @return    NOT YET DOCUMENTED
 */
public String toString() {
	String s = "";
	String nl = "\n\t";
	s += nl + "type: " + type;
	s += nl + "location: " + getLocation();
	if (getNamespace() != null && getNamespace() != Namespace.NO_NAMESPACE)
		s += nl + "namespace: " + getNamespace().getPrefix() + ": " + getNamespace().getURI();
	else
		s += nl + "namespace: null";
	return s;
}
 
Example 16
Project: joai-project   File: GenericType.java   Source Code and License Vote up 5 votes
/**
 *  NOT YET DOCUMENTED
 *
 * @return    NOT YET DOCUMENTED
 */
public String toString() {
	String s = "";
	String nl = "\n\t";
	s += nl + "type: " + type;
	s += nl + "location: " + getLocation();
	if (getNamespace() != null && getNamespace() != Namespace.NO_NAMESPACE)
		s += nl + "namespace: " + getNamespace().getPrefix() + ": " + getNamespace().getURI();
	else
		s += nl + "namespace: null";
	s += nl + this.getElementAsXml();
	return s;
}
 
Example 17
Project: dls-repository-stack   File: ReaderStack.java   Source Code and License Vote up 5 votes
/**
* Traverse the stack to find a SchemaReader that defines a namespace for the given prefix. Return null if
a reader is not found.
*/
public SchemaReader getReaderForPrefix (String prefix) {
	SchemaReader sr = null;
	prtln ("\tReaderStack.getReaderForPrefix() looking for prefix: " + prefix);
	for (int i=0; i < size(); i++) {
		sr = getItemAt(i);
		prtln ("\t\t " + sr.getLocation());
		Namespace ns = sr.getNamespaces().getNSforPrefix(prefix);
		if (ns != Namespace.NO_NAMESPACE) {
			prtln ("\t\t\t ... found reader at -- " + sr.getLocation().toString());
			break;
		}
	}
	return sr;
}
 
Example 18
Project: dls-repository-stack   File: ReaderStack.java   Source Code and License Vote up 5 votes
public GlobalDef getGlobalDef (String typeName) {
		prtln ("\ngetGlobalDef() typeName: " + typeName);
		prtln ("\n---------" + toString() + "\n-----------");
		SchemaReader schemaReader = getTos();
		Namespace namespace = schemaReader.getNamespaces().getTargetNamespace();
		String prefix = null;
		String baseName = typeName;
		boolean isMultiNamespace = globalDefMap.getNamespaces().isMultiNamespace();
		prtln ("\t isMultiNamespace: " + isMultiNamespace);
		if (NamespaceRegistry.isQualified(typeName)) {
			baseName = NamespaceRegistry.stripNamespacePrefix(typeName);
			prefix = NamespaceRegistry.getNamespacePrefix(typeName);
			if (prefix == null) prefix="";
			namespace = getNamespaceForPrefix(prefix);
			if (namespace == Namespace.NO_NAMESPACE) {
				prtln ("\t WARNING: namespace not found for \"" + typeName + "\"");
				return null;
			}
/* 			if (namespace == namespaces.getSchemaNamespace()) {
				// return null;
				prtln ("\t\t\t creating builtInType: " + NamespaceRegistry.makeQualifiedName(prefix, typeName));
				return new BuiltInType (NamespaceRegistry.makeQualifiedName(prefix, typeName));
			} */
		}
		// experimental 3/29/2007 - if there is a default Namespace, look in it for 
		
		else {
			prtln ("\t typeName is NOT qualified ... ");
			
			// try to use default name space, then use target ...
			Namespace defaultNamespace = schemaReader.getNamespaces().getDefaultNamespace();
			prtln ("\t\t default namespace is " + NamespaceRegistry.nsToString(namespace));
			if (defaultNamespace != Namespace.NO_NAMESPACE)
				namespace = defaultNamespace;
			
			prtln ("\t\t target namespace is " + NamespaceRegistry.nsToString(namespace));
		}
		return globalDefMap.getValue (baseName, namespace);
	}
 
Example 19
Project: dls-repository-stack   File: NamespaceRegistry.java   Source Code and License Vote up 5 votes
/**
 *  Gets the prefix corresponding to the provided uri after finding that uri's
 *  namespace.
 *
 * @param  uri  NOT YET DOCUMENTED
 * @return      The prefixforUri value
 */
public String getPrefixforUri(String uri) {
	Namespace ns = getNSforUri(uri);
	if (ns == Namespace.NO_NAMESPACE) {
		// prtln ("WARNING: getPrefixforUri() did not find namespace not found for " + uri);
	}
	return ns.getPrefix();
}
 
Example 20
Project: dls-repository-stack   File: SchemaReader.java   Source Code and License Vote up 5 votes
/**
 *  Gets the instanceQualifiedName attribute of the SchemaReader object
 *
 * @param  name  a type name from the local document
 * @return       The instanceQualifiedName value
 */
public String getInstanceQualifiedName(String name) {
	// prtln ("getInstanceQualifiedName() with " + name);
	Namespace namespace = targetNamespace;
	String prefix = null;
	String baseName = name;
	if (NamespaceRegistry.isQualified(name)) {
		baseName = NamespaceRegistry.stripNamespacePrefix(name);
		prefix = NamespaceRegistry.getNamespacePrefix(name);
		namespace = getNamespaces().getNSforPrefix(prefix);
		if (namespace == Namespace.NO_NAMESPACE) {
			prtln("\nWARNING: getInstanceQualifiedName can't find namespace for \"" + prefix + "\"");
			prtln("name: " + name);
			prtln("schemaReader.source: " + this.source);
			prtln(this.namespaces.toString());
			return null;
		}
	}

	NamespaceRegistry instanceNamespaces = this.getInstanceNamespaces();
	Namespace instanceNS = instanceNamespaces.getNSforUri(namespace.getURI());

	if (instanceNS.getPrefix().equals("")) {
		// if there is a namedDefaultNamespace at the instanceLevel, use it instead ...
		if (instanceNamespaces.getNamedDefaultNamespace() != Namespace.NO_NAMESPACE &&
			instanceNamespaces.isMultiNamespace()) {
			instanceNS = this.getInstanceNamespaces().getNamedDefaultNamespace();
		}
	}

	return NamespaceRegistry.makeQualifiedName(instanceNS, baseName);
}
 
Example 21
Project: dls-repository-stack   File: GlobalDeclaration.java   Source Code and License Vote up 5 votes
/**
 *  NOT YET DOCUMENTED
 *
 * @return    NOT YET DOCUMENTED
 */
public String toString() {
	String s = "";
	String nl = "\n\t";
	s += nl + "type: " + type;
	s += nl + "location: " + getLocation();
	if (getNamespace() != null && getNamespace() != Namespace.NO_NAMESPACE)
		s += nl + "namespace: " + getNamespace().getPrefix() + ": " + getNamespace().getURI();
	else
		s += nl + "namespace: null";
	return s;
}
 
Example 22
Project: dls-repository-stack   File: GenericType.java   Source Code and License Vote up 5 votes
/**
 *  Return string representation
 *
 * @return    debugging representation
 */
public String toString() {
	String s = "";
	String nl = "\n\t";
	s += nl + "type: " + type;
	s += nl + "location: " + getLocation();
	if (getNamespace() != null && getNamespace() != Namespace.NO_NAMESPACE)
		s += nl + "namespace: " + getNamespace().getPrefix() + ": " + getNamespace().getURI();
	else
		s += nl + "namespace: null";
	s += nl + this.getElementAsXml();
	return s;
}
 
Example 23
Project: jaxen   File: DocumentNavigator.java   Source Code and License Vote up 5 votes
public Iterator getNamespaceAxisIterator(Object contextNode)
{
    if ( ! ( contextNode instanceof Element ) )
    {
        return JaxenConstants.EMPTY_ITERATOR;
    }

    Element element = (Element) contextNode;
    List nsList = new ArrayList();
    HashSet prefixes = new HashSet();
    for ( Element context = element; context != null; context = context.getParent() ) {
        List declaredNS = new ArrayList(context.declaredNamespaces());
        declaredNS.add(context.getNamespace());

        for ( Iterator iter = context.attributes().iterator(); iter.hasNext(); )
        {
            Attribute attr = (Attribute) iter.next();
            declaredNS.add(attr.getNamespace());
        }

        for ( Iterator iter = declaredNS.iterator(); iter.hasNext(); )
        {
            Namespace namespace = (Namespace) iter.next();
            if (namespace != Namespace.NO_NAMESPACE)
            {
                String prefix = namespace.getPrefix();
                if ( ! prefixes.contains( prefix ) ) {
                    prefixes.add( prefix );
                    nsList.add( namespace.asXPathResult( element ) );
                }
            }
        }
    }
    nsList.add( Namespace.XML_NAMESPACE.asXPathResult( element ) );
    return nsList.iterator();
}