Java Code Examples for com.sun.xml.xsom.XSAttributeUse#isRequired()

The following examples show how to use com.sun.xml.xsom.XSAttributeUse#isRequired() . 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 attributeUse( XSAttributeUse use ) {
    XSAttributeDecl decl = use.getDecl();

    String additionalAtts="";

    if(use.isRequired())
        additionalAtts += " use=\"required\"";
    if(use.getFixedValue()!=null && use.getDecl().getFixedValue()==null)
        additionalAtts += " fixed=\""+use.getFixedValue()+'\"';
    if(use.getDefaultValue()!=null && use.getDecl().getDefaultValue()==null)
        additionalAtts += " default=\""+use.getDefaultValue()+'\"';

    if(decl.isLocal()) {
        // this is anonymous attribute use
        dump(decl,additionalAtts);
    } else {
        // reference to a global one
        println(MessageFormat.format("<attribute ref=\"'{'{0}'}'{1}{2}\"/>",
            new Object[]{ decl.getTargetNamespace(), decl.getName(),
                additionalAtts }));
    }
}
 
Example 2
Source File: JumbuneSchemaWriter.java    From jumbune with GNU Lesser General Public License v3.0 6 votes vote down vote up
public void attributeUse( XSAttributeUse use ) {
    XSAttributeDecl decl = use.getDecl();

    String additionalAtts="";

    if(use.isRequired())
        additionalAtts += " use=\"required\"";
    if(use.getFixedValue()!=null && use.getDecl().getFixedValue()==null)
        additionalAtts += " fixed=\""+use.getFixedValue()+'\"';
    if(use.getDefaultValue()!=null && use.getDecl().getDefaultValue()==null)
        additionalAtts += " default=\""+use.getDefaultValue()+'\"';

    if(decl.isLocal()) {
        // this is anonymous attribute use
        dump(decl,additionalAtts);
    } else {
        // reference to a global one
        println(MessageFormat.format("<attribute ref=\"{0}{1}\"{2}/>",
            decl.getTargetNamespace(), decl.getName(), additionalAtts));
    }
}
 
Example 3
Source File: SchemaWriter.java    From citygml4j with Apache License 2.0 6 votes vote down vote up
public void attributeUse( XSAttributeUse use ) {
	XSAttributeDecl decl = use.getDecl();

	String additionalAtts="";

	if(use.isRequired())
		additionalAtts += " use=\"required\"";
	if(use.getFixedValue()!=null && use.getDecl().getFixedValue()==null)
		additionalAtts += " fixed=\""+use.getFixedValue()+'\"';
	if(use.getDefaultValue()!=null && use.getDecl().getDefaultValue()==null)
		additionalAtts += " default=\""+use.getDefaultValue()+'\"';

	if(decl.isLocal()) {
		// this is anonymous attribute use
		dump(decl,additionalAtts);
	} else {
		// reference to a global one
		println(MessageFormat.format("<attribute ref=\"'{'{0}'}'{1}{2}\"/>",
				decl.getTargetNamespace(), decl.getName(), additionalAtts));
	}
}
 
Example 4
Source File: XmlFormBuilder.java    From dynaform with Artistic License 2.0 6 votes vote down vote up
public XmlForm attributeUse(XSAttributeUse use) {
  boolean required = use.isRequired();
  
  if (log.isDebugEnabled())
    log.debug("Attribute Use: " + use +
        ", Required: " + required);
  
  XSAttributeDecl decl = use.getDecl();

  XmlForm xmlForm = decl.apply(this);

  if (required) {
    Form form = xmlForm.getForm();
    if (form instanceof FormElement<?>)
      ((FormElement<?>) form).setRequired(true);
  }
  
  return xmlForm;
}
 
Example 5
Source File: SchemaTreeTraverser.java    From jolie with GNU Lesser General Public License v2.1 5 votes vote down vote up
public void attributeUse(XSAttributeUse use) {
    XSAttributeDecl decl = use.getDecl();

    String additionalAtts = "";

    if (use.isRequired()) {
        additionalAtts += " use=\"required\"";
    }
    if (use.getFixedValue() != null
            && use.getDecl().getFixedValue() == null) {
        additionalAtts += " fixed=\"" + use.getFixedValue() + "\"";
    }
    if (use.getDefaultValue() != null
            && use.getDecl().getDefaultValue() == null) {
        additionalAtts += " default=\"" + use.getDefaultValue() + "\"";
    }

    if (decl.isLocal()) {
        // this is anonymous attribute use
        dump(decl, additionalAtts);
    }
    else {
        // reference to a global one
        String str = MessageFormat.format(
                "Attribute ref \"'{'{0}'}'{1}{2}\"", new Object[]{
                    decl.getTargetNamespace(), decl.getName(),
                    additionalAtts});
        SchemaTreeNode newNode = new SchemaTreeNode(str, decl.getLocator());
        this.currNode.add(newNode);
    }
}
 
Example 6
Source File: ParticleMultiplicityCounter.java    From jsonix-schema-compiler with BSD 2-Clause "Simplified" License 4 votes vote down vote up
@Override
public Multiplicity attributeUse(XSAttributeUse use) {
	return use.isRequired() ? Multiplicity.ONE : Multiplicity.OPTIONAL;
}