public String write(XSAttributeDeclaration decl) XSTypeDefinition xst = decl.getTypeDefinition(); if (xst == null) throw MESSAGES.illegalNullArgument("Type xst"); boolean isGlobalRef = (decl.getScope() == XSConstants.SCOPE_GLOBAL); boolean isAnonType = xst.getAnonymous(); String name = decl.getName(); String prefix = null; String namespace = decl.getNamespace(); prefix = getPrefix(namespace); buf.append("<attribute ref='" + prefix + ":" + name + "'");
private QName getQName( XSAttributeDeclaration attrUse ) { if ( attrUse.getNamespace() == null || attrUse.getNamespace().isEmpty() ) { return new QName( attrUse.getName() ); } return new QName( attrUse.getNamespace(), attrUse.getName() ); }
private ATreeNode( XSAttributeDeclaration attrDeclaration ) throws OdaException { this(); this.attr = attrDeclaration; this.value = this.attr.getName( ); this.type = ATTRIBUTE_TYPE; this.dataType = getDataType( attrDeclaration.getTypeDefinition( ) .getName( ) ); }
private void addRelatedAttribute(XSAttributeDeclaration decl, Vector componentList, String namespace, Hashtable dependencies) { if (decl.getScope() == XSConstants.SCOPE_GLOBAL) { if (!componentList.contains(decl)) { Vector importedNamespaces = findDependentNamespaces(namespace, dependencies); addNamespaceDependency(namespace, decl.getNamespace(), importedNamespaces); componentList.add(decl); } } else { expandRelatedAttributeComponents(decl, componentList, namespace, dependencies); } }
for ( int i = 0; i < xsdValueType.getAttributeUses().getLength(); i++ ) { XSAttributeDeclaration attrDecl = ( (XSAttributeUse) xsdValueType.getAttributeUses().item( i ) ).getAttrDeclaration(); QName name = new QName( attrDecl.getNamespace(), attrDecl.getName() ); attrDecls.put( name, attrDecl ); String value = xmlStream.getAttributeValue( i ); PrimitiveValue xmlValue = new PrimitiveValue( value, new PrimitiveType( attrDecl.getTypeDefinition() ) ); attrs.put( name, xmlValue ); if ( attrUse.getRequired() ) { XSAttributeDeclaration attrDecl = attrUse.getAttrDeclaration(); QName name = new QName( attrDecl.getNamespace(), attrDecl.getName() ); if ( !attrs.containsKey( name ) ) { String msg = "Required attribute '" + name + "' is missing.";
XSAttributeUse au = (XSAttributeUse) attrs.item(i); XSAttributeDeclaration ad = au.getAttrDeclaration(); XSSimpleTypeDefinition atd = ad.getTypeDefinition(); XSAnnotation ann = ad.getAnnotation(); String documentation = parseAnnotationString( "Attribute " + ad.getNamespace() + ":" + ad.getName() + " documentation", ann != null ? ann.getAnnotationString() : null ); if (ad.getConstraintType() == XSConstants.VC_FIXED) { continue; Util.toJavaFieldName(ad.getName()), "String", null, au.getRequired() ); fd1.tagName = ad.getName(); fd1.documentation = documentation; fd1.realIndex = td.fdMap.size(); td.duplicates = Util.addToNameMap(td.fdMap, fd1, false) || td.duplicates; if (!"collectiontype".equals(ad.getName()) && checkEnumType(ad.getTypeDefinition())) { XSTypeDefinition etRoot = ad.getTypeDefinition(); if (etRoot.getAnonymous()) { etRoot = makeTypeFromAnonymous(ad); fd1.simpleTypesString = getSimpleTypesString(ad.getTypeDefinition());
private void expandRelatedAttributeComponents(XSAttributeDeclaration decl, Vector componentList, String namespace, Hashtable dependencies) { addRelatedType(decl.getTypeDefinition(), componentList, namespace, dependencies); /*final XSComplexTypeDefinition enclosingType = decl.getEnclosingCTDefinition(); if (enclosingType != null) { addRelatedType(enclosingType, componentList, namespace, dependencies); }*/ }
/** * Add an XSAttributeDeclaration */ public void addXSAttributeDeclaration(XSAttributeDeclaration att) { if(att == null) throw NativeMessages.MESSAGES.illegalNullArgument("att"); attrs.put(att.getName(),att); }
public void addXSAttributeDeclaration(XSAttributeDeclaration attr) { //Add attribute to the namespace item String ns = attr.getNamespace(); JBossXSNamespaceItem jbnm = createNamespaceItemIfNotExistent(ns); jbnm.addXSAttributeDeclaration(attr); }
private void componentScope(XSObject sourceComponent, List targetComponents) { switch (sourceComponent.getType()) { case XSConstants.ATTRIBUTE_DECLARATION: if (((XSAttributeDeclaration)sourceComponent).getScope() != XSConstants.SCOPE_GLOBAL) { XSObject type = ((XSAttributeDeclaration)sourceComponent).getEnclosingCTDefinition(); if (type != null && !targetComponents.contains(type)) { targetComponents.add(type); } } break; case XSConstants.ELEMENT_DECLARATION: if (((XSElementDeclaration)sourceComponent).getScope() != XSConstants.SCOPE_GLOBAL) { XSObject type = ((XSElementDeclaration)sourceComponent).getEnclosingCTDefinition(); if (type != null && !targetComponents.contains(type)) { targetComponents.add(type); } } break; } } // componentScope()
private void preProcessXSAttributeUse(XSAttributeUse attr) throws Exception { XSAttributeDeclaration decl = attr.getAttrDeclaration(); String sampleValue = null; switch (attr.getConstraintType()) { case XSConstants.VC_FIXED: if (RandomUtil.randomBoolean(config.generateFixedAttributes)) { sampleValue = attr.getValueConstraintValue().getNormalizedValue(); } break; case XSConstants.VC_DEFAULT: if (RandomUtil.randomBoolean(config.generateDefaultAttributes)) { sampleValue = attr.getValueConstraintValue().getNormalizedValue(); } break; default: if (attr.getRequired() || RandomUtil.randomBoolean(config.generateOptionalAttributes)) { if (sampleValue == null) { sampleValue = generateSampleValue(config, decl.getTypeDefinition(), decl.getName(), counters); } } } if (sampleValue != null) { doc.addAttribute(decl.getNamespace(), decl.getName(), sampleValue); } }
private boolean allowsXLink( XSComplexTypeDefinition typeDef ) { XSObjectList xsObjectList = typeDef.getAttributeUses(); for ( int i = 0; i < xsObjectList.getLength(); i++ ) { XSAttributeDeclaration attr = ( (XSAttributeUse) xsObjectList.item( i ) ).getAttrDeclaration(); if ( "href".equals( attr.getName() ) && XLNNS.equals( attr.getNamespace() ) ) { return true; } } return false; }
private AttributeBinding bindAttribute(XSAttributeUse attrUse) QName attrName = new QName(attr.getNamespace(), attr.getName()); XSSimpleTypeDefinition attrType = attr.getTypeDefinition(); TypeBinding typeBinding = bindSimpleType(attrType); XSAnnotation an = attr.getAnnotation(); if(an != null)
public TypeDefinition lookupAttributeDeclaration(String namespace, String attributeName) { XSAttributeDeclaration ad = _schema.getAttributeDeclaration(attributeName, namespace); return XercesTypeDefinition.createTypeDefinition(ad.getTypeDefinition()); }
private void processAttribute(Path parent, String path, XSAttributeUse xsAttribute) throws BagriException { path += "/@" + xsAttribute.getAttrDeclaration().getName(); XSSimpleTypeDefinition std = xsAttribute.getAttrDeclaration().getTypeDefinition(); Occurrence occurrence = Occurrence.getOccurrence( xsAttribute.getRequired() ? 1 : 0, std.getVariety() == XSSimpleTypeDefinition.VARIETY_LIST ? -1 : 1); Path xp = modelMgr.translatePath(parent.getRoot(), path, NodeKind.attribute, parent.getPathId(), getBaseType(std), occurrence); logger.trace("processAttribute; attribute: {}; type: {}; got XDMPath: {}", path, std, xp); }
for ( int i = 0; i < attributeUses.getLength(); i++ ) { XSAttributeUse attributeUse = (XSAttributeUse) attributeUses.item( i ); s += "\n - attribute: " + attributeUse.getAttrDeclaration().getName();
if (((XSAttributeDeclaration)sourceComponent).getScope() == XSConstants.SCOPE_LOCAL) { addComponent(((XSAttributeDeclaration)sourceComponent).getEnclosingCTDefinition(), nameTest, targetComponents);
for ( int i = 0; i < xsdValueType.getAttributeUses().getLength(); i++ ) { XSAttributeDeclaration attrDecl = ( (XSAttributeUse) xsdValueType.getAttributeUses().item( i ) ).getAttrDeclaration(); QName name = new QName( attrDecl.getNamespace(), attrDecl.getName() ); attrDecls.put( name, attrDecl ); new PrimitiveType( attrDecl.getTypeDefinition() ) ); attrs.put( name, xmlValue ); if ( attrUse.getRequired() ) { XSAttributeDeclaration attrDecl = attrUse.getAttrDeclaration(); QName name = new QName( attrDecl.getNamespace(), attrDecl.getName() ); if ( !attrs.containsKey( name ) ) { String msg = "Required attribute '" + name + "' is missing.";
private boolean isInheritedAttributeOverridden(XMLAttributes attributes, XSAttributeDeclaration inhrAttrDecl) { boolean attrExists = false; for (int attrIndx = 0; attrIndx < attributes.getLength(); attrIndx++) { if ((attributes.getLocalName(attrIndx)).equals(inhrAttrDecl.getName()) && XS11TypeHelper.isURIEqual(attributes.getURI(attrIndx), inhrAttrDecl.getNamespace())) { attrExists = true; break; } } return attrExists; } // isInheritedAttributeOverridden
private void addElidedComponents(XSObject sourceComponent) { // these are the components returned from the term() accessor whose component-kind() is equal to xscd:model-group // currentComponents.size() gets changed in each iteration for (int i = currentComponents.size() - 1; i < currentComponents.size(); ++i) { term((XSObject)currentComponents.get(i), XSConstants.MODEL_GROUP, SCDParser.WILDCARD, currentComponents); } switch (sourceComponent.getType()) { case XSConstants.ELEMENT_DECLARATION: { XSObject typeDef = ((XSElementDeclaration)sourceComponent).getTypeDefinition(); if (typeDef != null && !currentComponents.contains(typeDef)) { currentComponents.add(typeDef); } } break; case XSConstants.ATTRIBUTE_DECLARATION: { XSObject typeDef = ((XSAttributeDeclaration)sourceComponent).getTypeDefinition(); if (typeDef != null && !currentComponents.contains(typeDef)) { currentComponents.add(typeDef); } } break; } // TODO: we dont have type alternative for now. } // getElidedComponents()