org.apache.xerces.xs.XSWildcard Java Examples

The following examples show how to use org.apache.xerces.xs.XSWildcard. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CMXSDElementDeclaration.java    From lemminx with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * Returns the possible elements declaration if the given declaration is an
 * xs:any and null otherwise.
 * 
 * @param declaration the element, wildcard declaration.
 * @return the possible elements declaration if the given declaration is an
 *         xs:any and null otherwise.
 * 
 */
private Collection<CMElementDeclaration> getXSAnyElements(Object declaration) {
	short processContents = getXSAnyProcessContents(declaration);
	if (processContents != PC_UNKWOWN) {
		// xs:any
		switch (processContents) {
		case XSWildcard.PC_STRICT:
		case XSWildcard.PC_SKIP:
			// <xs:any processContents="strict" /> or <xs:any processContents="skip" />
			// only global element declaration from the XML Schema are allowed
			return document.getElements();
		default:
			// <xs:any processContents="lax" />
			// all tags are allowed.
			return ANY_ELEMENT_DECLARATIONS;
		}
	}
	return null;
}
 
Example #2
Source File: XmlTypeToJsonSchemaConverter.java    From iaf with Apache License 2.0 6 votes vote down vote up
private void handleWildcard(XSWildcard wildcard){
	String processContents;
	switch (wildcard.getProcessContents()) {
	case XSWildcard.PC_LAX: processContents="LAX"; break;
	case XSWildcard.PC_SKIP: processContents="SKIP"; break;
	case XSWildcard.PC_STRICT: processContents="STRICT"; break;
	default: 
			throw new IllegalStateException("handleWildcard wildcard.processContents is not PC_LAX, PC_SKIP or PC_STRICT, but ["+wildcard.getProcessContents()+"]");
	}
	String namespaceConstraint;
	switch (wildcard.getConstraintType()) {
	case XSWildcard.NSCONSTRAINT_ANY : namespaceConstraint="ANY"; break;
	case XSWildcard.NSCONSTRAINT_LIST : namespaceConstraint="SKIP "+wildcard.getNsConstraintList(); break;
	case XSWildcard.NSCONSTRAINT_NOT : namespaceConstraint="NOT "+wildcard.getNsConstraintList(); break;
	default: 
			throw new IllegalStateException("handleWildcard wildcard.namespaceConstraint is not ANY, LIST or NOT, but ["+wildcard.getConstraintType()+"]");
	}
}
 
Example #3
Source File: CMXSDElementDeclaration.java    From lemminx with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Returns the value of the xs:any/@processContents if the given element is a
 * xs:any and {@link #PC_UNKWOWN} otherwise.
 * 
 * @param declaration the element, wildcard declaration.
 * @return the value of the xs:any/@processContents if the given element is a
 *         xs:any and {@link #PC_UNKWOWN} otherwise.
 */
private static short getXSAnyProcessContents(Object declaration) {
	if (declaration instanceof XSWildcard) {
		XSWildcard wildcard = (XSWildcard) declaration;
		if ((wildcard.getConstraintType() == XSWildcard.NSCONSTRAINT_ANY)) {
			return wildcard.getProcessContents();
		}
	}
	return PC_UNKWOWN;
}
 
Example #4
Source File: XmlTypeToJsonSchemaConverter.java    From iaf with Apache License 2.0 5 votes vote down vote up
public void handleTerm(JsonObjectBuilder builder, XSTerm term, XSObjectList attributeUses, boolean multiOccurring, boolean forProperties) {
	if (term instanceof XSModelGroup) {
		handleModelGroup(builder, (XSModelGroup)term, attributeUses, forProperties);
		return;
	} 
	if (term instanceof XSElementDeclaration) {
		XSElementDeclaration elementDeclaration = (XSElementDeclaration)term;
		if (elementDeclaration.getScope()==XSConstants.SCOPE_GLOBAL) {
			JsonObject typeDefininition = Json.createObjectBuilder().add("$ref", "#/definitions/"+elementDeclaration.getName()).build();
			if (multiOccurring) {
				JsonObjectBuilder arrayBuilder = Json.createObjectBuilder();
				arrayBuilder.add("type", "array");
				arrayBuilder.add("items", typeDefininition);

				builder.add(elementDeclaration.getName(), arrayBuilder.build());
			} else {
				builder.add(elementDeclaration.getName(), typeDefininition);
			}
		} else {
			handleElementDeclaration(builder, elementDeclaration, multiOccurring, true);
		}
		return;
	}
	if (term instanceof XSWildcard) {
		handleWildcard((XSWildcard)term);
		return;
	} 
	throw new IllegalStateException("handleTerm unknown Term type ["+term.getClass().getName()+"]");
}
 
Example #5
Source File: XSColorVisitor.java    From jlibs with Apache License 2.0 4 votes vote down vote up
@SuppressWarnings({"UnusedDeclaration"})
protected Color process(XSWildcard wildcard){
    return COLOR_ELEMENT;
}