Java Code Examples for org.dom4j.Element.getNamespacePrefix()

The following are Jave code examples for showing how to use getNamespacePrefix() of the org.dom4j.Element class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: joai-project   File: StructureWalker.java   View Source Code Vote up 6 votes
/**
 *  Test if the "type" (or "ref") attribute of the given Schema Element
 *  designates a built-in datatype, as opposed to a derived type.<p>
 *
 *  An qualified attribute value is determined to be BuiltIn if it has the same
 *  prefix as the qualified name of the element in which it is defined.<p>
 *
 *  E.g., in the following element, the type is "xs:string", which is a
 *  built-in type: &lt;xs:element name="artist" type="xs:string"/>.
 *
 * @param  e  Description of the Parameter
 * @return    true if the given schema element refers to a built-in datatype.
 */
private boolean isBuiltInType(Element e) {
	String prefix = e.getNamespacePrefix();
	String type = e.attributeValue("type", null);
	if (type == null) {
		type = e.attributeValue("ref", null);
	}
	if (type == null) {
		return false;
	}

	String typePrefix = NamespaceRegistry.getNamespacePrefix(type);
	if (prefix != null && (prefix.equals(typePrefix) || typePrefix.equals("xml"))) {
		return true;
	}
	else {
		return false;
	}
}
 
Example 2
Project: joai-project   File: XSDatatypeManager.java   View Source Code Vote up 5 votes
/**
*  Given a restriction element, return the value of the <i>base</i> attribute. 
	Currently requires
 *  that a "xsd:" prefix is present in the base attribute, and remove the prefix before returning remainder
 *  of base attribute. 
 
 @see #deriveByRestriction(SimpleType)
 *
 *@param  e  Description of the Parameter
 *@return    The baseName value
 */
private String getBaseRestrictionName(Element e) {
	String bn = e.valueOf("@base");
	String prefix = e.getNamespacePrefix()+":";
	if (!bn.startsWith(prefix)) {
		// prtln ("getBaseRestrictionName report");
		// prtln ("\tnamespaceURI: " + e.getNamespaceURI());
		
		// return null;
		return bn;
	}
	else {
		return bn.substring(prefix.length());
	}
}