Java Code Examples for org.apache.xerces.xs.XSAttributeDeclaration#getTypeDefinition()
The following examples show how to use
org.apache.xerces.xs.XSAttributeDeclaration#getTypeDefinition() .
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: CMXSDAttributeDeclaration.java From lemminx with Eclipse Public License 2.0 | 6 votes |
/** * Returns list of xs:annotation from the element declaration or type * declaration. * * @return list of xs:annotation from the element declaration or type * declaration. */ private XSObjectList getAnnotations() { // Try get xs:annotation from the element declaration XSAttributeDeclaration attributeDeclaration = getAttrDeclaration(); XSObjectList annotation = attributeDeclaration.getAnnotations(); if (annotation != null && annotation.getLength() > 0) { return annotation; } // Try get xs:annotation from the type of element declaration XSTypeDefinition typeDefinition = attributeDeclaration.getTypeDefinition(); if (typeDefinition == null) { return null; } if (typeDefinition.getTypeCategory() == XSTypeDefinition.COMPLEX_TYPE) { return ((XSComplexTypeDecl) typeDefinition).getAnnotations(); } else if (typeDefinition.getTypeCategory() == XSTypeDefinition.SIMPLE_TYPE) { return ((XSSimpleTypeDecl) typeDefinition).getAnnotations(); } return null; }
Example 2
Source File: CMXSDAttributeDeclaration.java From lemminx with Eclipse Public License 2.0 | 5 votes |
/** * Returns list of xs:annotation from the element declaration or type * declaration. * * Indicated by: * https://msdn.microsoft.com/en-us/library/ms256143(v=vs.110).aspx * xs:attribute tags have content of either an xs:annotation or xs:simpleType * * @return list of xs:annotation from the element declaration or type * declaration. */ private XSObjectList getValueAnnotations() { // Try get xs:annotation from the element declaration XSAttributeDeclaration attributeDeclaration = getAttrDeclaration(); XSSimpleTypeDefinition simpleTypeDefinition = attributeDeclaration.getTypeDefinition(); XSSimpleTypeDecl simpleTypeDecl; XSObjectList annotation = null; // The XSD tag that holds the documentation tag if(simpleTypeDefinition instanceof XSSimpleTypeDecl) { simpleTypeDecl = (XSSimpleTypeDecl) simpleTypeDefinition; XSObjectList multiFacets = simpleTypeDecl.getMultiValueFacets(); if(!multiFacets.isEmpty()) { XSMultiValueFacet facet = (XSMultiValueFacet) multiFacets.get(0); multiFacets = facet.getAnnotations(); Object[] annotationArray = multiFacets.toArray(); if(!onlyContainsNull(annotationArray)) { // if multiValueFacets has annotations annotation = simpleTypeDecl.getMultiValueFacets(); } } } if(annotation == null){ // There was no specific documentation for the value, so use the general attribute documentation annotation = attributeDeclaration.getAnnotations(); } if (annotation != null && annotation.getLength() > 0) { return annotation; } // Try get xs:annotation from the type of element declaration XSTypeDefinition typeDefinition = attributeDeclaration.getTypeDefinition(); if (typeDefinition == null) { return null; } if (typeDefinition.getTypeCategory() == XSTypeDefinition.COMPLEX_TYPE) { return ((XSComplexTypeDecl) typeDefinition).getAnnotations(); } else if (typeDefinition.getTypeCategory() == XSTypeDefinition.SIMPLE_TYPE) { return ((XSSimpleTypeDecl) typeDefinition).getAnnotations(); } return null; }
Example 3
Source File: CMXSDAttributeDeclaration.java From lemminx with Eclipse Public License 2.0 | 5 votes |
@Override public Collection<String> getEnumerationValues() { XSAttributeDeclaration attributeDeclaration = getAttrDeclaration(); if (attributeDeclaration != null) { XSSimpleTypeDefinition typeDefinition = attributeDeclaration.getTypeDefinition(); return CMXSDDocument.getEnumerationValues(typeDefinition); } return Collections.emptyList(); }
Example 4
Source File: XmlTo.java From iaf with Apache License 2.0 | 4 votes |
@Override public void startElement(String uri, String localName, String qName, Attributes atts) throws SAXException { boolean xmlArrayContainer=aligner.isParentOfSingleMultipleOccurringChildElement(); boolean repeatedElement=aligner.isMultipleOccurringChildInParentElement(localName); XSTypeDefinition typeDefinition=aligner.getTypeDefinition(); if (!localName.equals(topElement)) { if (topElement!=null) { if (log.isTraceEnabled()) log.trace("endElementGroup ["+topElement+"]"); documentContainer.endElementGroup(topElement); } if (log.isTraceEnabled()) log.trace("startElementGroup ["+localName+"]"); documentContainer.startElementGroup(localName, xmlArrayContainer, repeatedElement, typeDefinition); topElement=localName; } element.push(topElement); topElement=null; if (log.isTraceEnabled()) log.trace("startElement ["+localName+"] xml array container ["+aligner.isParentOfSingleMultipleOccurringChildElement()+"] repeated element ["+aligner.isMultipleOccurringChildInParentElement(localName)+"]"); documentContainer.startElement(localName,xmlArrayContainer,repeatedElement, typeDefinition); super.startElement(uri, localName, qName, atts); if (aligner.isNil(atts)) { documentContainer.setNull(); } else { if (writeAttributes) { XSObjectList attributeUses=aligner.getAttributeUses(); if (attributeUses==null) { if (atts.getLength()>0) { log.warn("found ["+atts.getLength()+"] attributes, but no declared AttributeUses"); } } else { for (int i=0;i<attributeUses.getLength(); i++) { XSAttributeUse attributeUse=(XSAttributeUse)attributeUses.item(i); XSAttributeDeclaration attributeDeclaration=attributeUse.getAttrDeclaration(); XSSimpleTypeDefinition attTypeDefinition=attributeDeclaration.getTypeDefinition(); String attName=attributeDeclaration.getName(); String attNS=attributeDeclaration.getNamespace(); if (log.isTraceEnabled()) log.trace("startElement ["+localName+"] searching attribute ["+attNS+":"+attName+"]"); int attIndex=attNS!=null? atts.getIndex(attNS, attName):atts.getIndex(attName); if (attIndex>=0) { String value=atts.getValue(attIndex); if (log.isTraceEnabled()) log.trace("startElement ["+localName+"] attribute ["+attNS+":"+attName+"] value ["+value+"]"); if (StringUtils.isNotEmpty(value)) { documentContainer.setAttribute(attName, value, attTypeDefinition); } } } } } } }