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

The following examples show how to use com.sun.xml.xsom.XSAttributeUse#getDecl() . 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: ComplexTypeImpl.java    From jolie with GNU Lesser General Public License v2.1 6 votes vote down vote up
public Iterator<XSAttributeUse> iterateAttributeUses() {
    
    XSComplexType baseType = getBaseType().asComplexType();
    
    if( baseType==null )    return super.iterateAttributeUses();
    
    return new Iterators.Union<XSAttributeUse>(
        new Iterators.Filter<XSAttributeUse>(baseType.iterateAttributeUses()) {
            protected boolean matches(XSAttributeUse value) {
                XSAttributeDecl u = value.getDecl();
                UName n = new UName(u.getTargetNamespace(),u.getName());
                return !prohibitedAtts.contains(n);
            }
        },
        super.iterateAttributeUses() );
}
 
Example 3
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 4
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 5
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 6
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 7
Source File: Axis.java    From jolie with GNU Lesser General Public License v2.1 5 votes vote down vote up
private Iterator<XSAttributeDecl> attributeHolder(final XSAttContainer atts) {
    // TODO: check spec. is this correct?
    return new Iterators.Adapter<XSAttributeDecl,XSAttributeUse>(atts.iterateAttributeUses()) {
        protected XSAttributeDecl filter(XSAttributeUse u) {
            return u.getDecl();
        }
    };
}
 
Example 8
Source File: XmlFormBuilder.java    From dynaform with Artistic License 2.0 5 votes vote down vote up
private void attributes(List<Form> forms,
    Map<String, TextWriter> attrWriters,
    Map<String, TextHandler> attrReaders,
    Collection<? extends XSAttributeUse> attrs) {
  
  for (XSAttributeUse use : attrs) {
    XmlForm xmlForm = use.apply(this);
    if (xmlForm != null) {
      XSAttributeDecl attr = use.getDecl();
      String name = attr.getName();

      Form form = xmlForm.getForm();
      if (form != null)
        forms.add(form);

      XmlWriter writer = xmlForm.getWriter();
      if (writer instanceof TextXmlWriter) {
        TextWriter textWriter = ((TextXmlWriter) writer).getWriter();
        attrWriters.put(name, textWriter);
      }
      
      XmlReader reader = xmlForm.getReader();
      TextHandler handler = null;
      if (reader instanceof TextXmlReader) {
        TextXmlReader textXmlReader = (TextXmlReader) reader;
        handler = textXmlReader.getHandler();
      } else if (reader != null)
        throw new IllegalStateException("XmlReader " + reader + " cannot be assigned to an XML attribtue, TextXmlReader expected");
      if (handler != null)
        attrReaders.put(name, handler);
    }
  }
}