Java Code Examples for com.sun.xml.xsom.XSListSimpleType#getItemType()

The following examples show how to use com.sun.xml.xsom.XSListSimpleType#getItemType() . 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: SchemaWriter.java    From jolie with GNU Lesser General Public License v2.1 6 votes vote down vote up
public void listSimpleType( XSListSimpleType type ) {
    XSSimpleType itemType = type.getItemType();

    if(itemType.isLocal()) {
        println("<list>");
        indent++;
        simpleType(itemType);
        indent--;
        println("</list>");
    } else {
        // global type
        println(MessageFormat.format("<list itemType=\"'{'{0}'}'{1}\" />",
            new Object[]{
                itemType.getTargetNamespace(),
                itemType.getName()
            }));
    }
}
 
Example 2
Source File: JumbuneSchemaWriter.java    From jumbune with GNU Lesser General Public License v3.0 5 votes vote down vote up
public void listSimpleType( XSListSimpleType type ) {
    XSSimpleType itemType = type.getItemType();

    if(itemType.isLocal()) {
        println("<list>");
        indent++;
        simpleType(itemType);
        indent--;
        println("</list>");
    } else {
        // global type
        println(MessageFormat.format("<list itemType=\"'{'{0}'}'{1}\" />",
            itemType.getTargetNamespace(), itemType.getName()));
    }
}
 
Example 3
Source File: SchemaWriter.java    From citygml4j with Apache License 2.0 5 votes vote down vote up
public void listSimpleType( XSListSimpleType type ) {
	XSSimpleType itemType = type.getItemType();

	if(itemType.isLocal()) {
		println("<list>");
		indent++;
		simpleType(itemType);
		indent--;
		println("</list>");
	} else {
		// global type
		println(MessageFormat.format("<list itemType=\"'{'{0}'}'{1}\" />",
				itemType.getTargetNamespace(), itemType.getName()));
	}
}
 
Example 4
Source File: XmlFormBuilder.java    From dynaform with Artistic License 2.0 4 votes vote down vote up
private FormElement declSimple(XSSimpleType simpleType,
    String name,
    XmlString defaultValue,
    XmlString fixedValue) {
  
  if (log.isDebugEnabled()) {
    log.debug("Simple Type: " + simpleType);
    log.debug("Primitive: " + simpleType.isPrimitive());
  }
  
  Data data = null;
  Control control = null;
  boolean required = false;
  
  if (simpleType.isRestriction()) {
    XSRestrictionSimpleType restriction = simpleType.asRestriction();
    
    if (isEnumeration(restriction)) {
      control = new Controls.SelectOneImpl();
      if (log.isDebugEnabled())
        log.debug("Control: " + control);
    }
    
    required = hasMinLength(restriction);
    
    data = createData(simpleType);
    if (data == null) {
      log.warn("Unsupported Primitive Type: " + simpleType);
      return null;
    }
  }
  
  else if (simpleType.isList()) {
    XSListSimpleType list = simpleType.asList();
    XSSimpleType itemType = list.getItemType();
    
    if (log.isDebugEnabled()) {
      log.debug("List: " + list);
      log.debug("Item type: " + itemType);
    }
    
    data = new StringData();
  }
  
  else if (simpleType.isUnion()) {
    log.warn("Unsupported Simple Type: " + simpleType);
    return null;
  }
  
  else
    throw new AssertionError("Unknown Simple Type: " + simpleType);
  
  if (control == null)
    control = new Controls.InputImpl();
  
  String value = null;
  boolean readOnly = false;
  
  if (defaultValue != null) {
    if (log.isDebugEnabled())
      log.debug("Default Value: " + defaultValue);
    
    value = defaultValue.toString();
  }
  
  if (fixedValue != null) {
    if (log.isDebugEnabled())
      log.debug("Fixed Value: " + fixedValue);
    
    value = fixedValue.toString();
    readOnly = true;
  }
  
  FormElement element = new FormElementImpl(name, control, data);
  
  if (value != null) {
    try {
      element.setXmlValue(value);
    } catch (Exception e) {
      log.warn("Failed to inject XML value: " + value, e);
    }
  }
  
  if (simpleType.isRestriction())
    processRestrictions(simpleType.asRestriction(), element.getRestrictions());
  
  element.setReadOnly(readOnly);
  element.setRequired(required);
  
  return element;
}