List of usage examples for javax.xml.namespace QName getPrefix
public String getPrefix()
Get the prefix of this QName
.
The prefix assigned to a QName
might NOT be valid in a different context.
From source file:org.apache.abdera.util.AbstractStreamWriter.java
public StreamWriter writeAttribute(QName qname, int value) { return writeAttribute(qname.getLocalPart(), qname.getNamespaceURI(), qname.getPrefix(), value); }
From source file:org.apache.abdera.util.AbstractStreamWriter.java
public StreamWriter writeAttribute(QName qname, long value) { return writeAttribute(qname.getLocalPart(), qname.getNamespaceURI(), qname.getPrefix(), value); }
From source file:org.apache.abdera.util.AbstractStreamWriter.java
public StreamWriter writeAttribute(QName qname, double value) { return writeAttribute(qname.getLocalPart(), qname.getNamespaceURI(), qname.getPrefix(), value); }
From source file:org.apache.abdera2.writer.AbstractStreamWriter.java
public StreamWriter writeAttribute(QName qname, DateTime value) { return writeAttribute(qname.getLocalPart(), qname.getNamespaceURI(), qname.getPrefix(), value); }
From source file:org.apache.axiom.om.impl.llom.OMElementImpl.java
/** Method handleNamespace. */ OMNamespace handleNamespace(QName qname) { OMNamespace ns = null;/*from ww w. j a v a 2 s . com*/ // first try to find a namespace from the scope String namespaceURI = qname.getNamespaceURI(); if (namespaceURI != null && namespaceURI.length() > 0) { String prefix = qname.getPrefix(); ns = findNamespace(qname.getNamespaceURI(), prefix); /** * What is left now is * 1. nsURI = null & parent != null, but ns = null * 2. nsURI != null, (parent doesn't have an ns with given URI), but ns = null */ if (ns == null) { if ("".equals(prefix)) { prefix = OMSerializerUtil.getNextNSPrefix(); } ns = declareNamespace(namespaceURI, prefix); } if (ns != null) { this.ns = ns; } } return ns; }
From source file:org.apache.axiom.om.impl.llom.OMSourcedElementImpl.java
/** * Constructor that takes a QName instead of the local name and the namespace seperately * * @param qName//ww w . j av a 2 s . c o m * @param factory * @param source */ public OMSourcedElementImpl(QName qName, OMFactory factory, OMDataSource source) { //create a namespace super(qName.getLocalPart(), null, factory); dataSource = source; isExpanded = (dataSource == null); if (!isExpanded) { if (!isLossyPrefix(dataSource)) { // Believe the prefix and create a normal OMNamespace definedNamespace = new OMNamespaceImpl(qName.getNamespaceURI(), qName.getPrefix()); } else { // Create a deferred namespace that forces an expand to get the prefix definedNamespace = new DeferredNamespace(qName.getNamespaceURI()); } } else { definedNamespace = new OMNamespaceImpl(qName.getNamespaceURI(), qName.getPrefix()); } }
From source file:org.apache.axiom.soap.impl.llom.SOAPEnvelopeImpl.java
public OMNamespace getSOAPBodyFirstElementNS() { QName payloadQName = this.getPayloadQName_Optimized(); if (payloadQName != null) { return this.factory.createOMNamespace(payloadQName.getNamespaceURI(), payloadQName.getPrefix()); }/*from www .j av a2 s. c o m*/ SOAPBody body = this.getBody(); return (body == null) ? null : body.getFirstElementNS(); }
From source file:org.apache.axis2.addressing.EndpointReferenceHelper.java
/** * Creates an <code>OMElement</code> based on the properties of the endpoint * reference. The output may differ based on the addressing namespace that is * in effect when this method is called. If the http://www.w3.org/2005/08/addressing * namespace is in effect, and a metadata property has been defined for the * endpoint reference, then there will be a metadata element to contain the * property in the output. If the http://schemas.xmlsoap.org/ws/2004/08/addressing * namespace is in effect, however, then no metadata element will be included * in the output, even if a metadata property element has been defined. * * @param factory/* w w w . j av a2 s .c o m*/ * @param epr * @param qname * @param addressingNamespace * @return * @throws AxisFault */ public static OMElement toOM(OMFactory factory, EndpointReference epr, QName qname, String addressingNamespace) throws AxisFault { OMElement eprElement = null; if (log.isDebugEnabled()) { log.debug("toOM: Factory, " + factory); log.debug("toOM: Endpoint reference, " + epr); log.debug("toOM: Element qname, " + qname); log.debug("toOM: Addressing namespace, " + addressingNamespace); } if (addressingNamespace == null) { throw new AxisFault("Addressing namespace cannot be null."); } if (qname.getPrefix() != null) { OMNamespace wrapNs = factory.createOMNamespace(qname.getNamespaceURI(), qname.getPrefix()); if (factory instanceof SOAPFactory) { eprElement = ((SOAPFactory) factory).createSOAPHeaderBlock(qname.getLocalPart(), wrapNs); } else { eprElement = factory.createOMElement(qname.getLocalPart(), wrapNs); } OMNamespace wsaNS = factory.createOMNamespace(addressingNamespace, AddressingConstants.WSA_DEFAULT_PREFIX); OMElement addressE = factory.createOMElement(AddressingConstants.EPR_ADDRESS, wsaNS, eprElement); String address = epr.getAddress(); addressE.setText(address); ArrayList addressAttributes = epr.getAddressAttributes(); if (addressAttributes != null) { Iterator attrIter = addressAttributes.iterator(); while (attrIter.hasNext()) { OMAttribute omAttribute = (OMAttribute) attrIter.next(); AttributeHelper.importOMAttribute(omAttribute, addressE); } } List metaData = epr.getMetaData(); if (metaData != null && AddressingConstants.Final.WSA_NAMESPACE.equals(addressingNamespace)) { OMElement metadataE = factory.createOMElement(AddressingConstants.Final.WSA_METADATA, wsaNS, eprElement); for (int i = 0, size = metaData.size(); i < size; i++) { OMElement omElement = (OMElement) metaData.get(i); metadataE.addChild(ElementHelper.importOMElement(omElement, factory)); } ArrayList metadataAttributes = epr.getMetadataAttributes(); if (metadataAttributes != null) { Iterator attrIter = metadataAttributes.iterator(); while (attrIter.hasNext()) { OMAttribute omAttribute = (OMAttribute) attrIter.next(); AttributeHelper.importOMAttribute(omAttribute, metadataE); } } } Map referenceParameters = epr.getAllReferenceParameters(); if (referenceParameters != null) { OMElement refParameterElement = factory .createOMElement(AddressingConstants.EPR_REFERENCE_PARAMETERS, wsaNS, eprElement); Iterator iterator = referenceParameters.values().iterator(); while (iterator.hasNext()) { OMElement omElement = (OMElement) iterator.next(); refParameterElement.addChild(ElementHelper.importOMElement(omElement, factory)); } } List attributes = epr.getAttributes(); if (attributes != null) { for (int i = 0, size = attributes.size(); i < size; i++) { OMAttribute omAttribute = (OMAttribute) attributes.get(i); AttributeHelper.importOMAttribute(omAttribute, eprElement); } } // add xs:any List extensibleElements = epr.getExtensibleElements(); if (extensibleElements != null) { for (int i = 0, size = extensibleElements.size(); i < size; i++) { OMElement omElement = (OMElement) extensibleElements.get(i); eprElement.addChild(ElementHelper.importOMElement(omElement, factory)); } } } else { throw new AxisFault("prefix must be specified"); } return eprElement; }
From source file:org.apache.axis2.corba.receivers.CorbaUtil.java
private static OMNamespace getNameSpaceForType(SOAPFactory fac, AxisService service, CompositeDataType dataType) {/* w ww . j av a 2s . co m*/ TypeTable typeTable = service.getTypeTable(); String fullname = (dataType.getModule() != null) ? dataType.getModule() + dataType.getName() : dataType.getName(); fullname = fullname.replaceAll(CompositeDataType.MODULE_SEPERATOR, "."); QName qname = typeTable.getQNamefortheType(fullname); if (qname == null) return null; return fac.createOMNamespace(qname.getNamespaceURI(), qname.getPrefix()); }
From source file:org.apache.axis2.description.java2wsdl.DefaultSchemaGenerator.java
/** * Generate schema construct for given type * * @param javaType : Class to whcih need to generate Schema * @return : Generated QName//from ww w . ja v a 2s . com */ protected QName generateSchema(Class<?> javaType) throws Exception { String name = getClassName(javaType); QName schemaTypeName = typeTable.getComplexSchemaType(name); if (schemaTypeName == null) { String simpleName = getSimpleClassName(javaType); String packageName = getQualifiedName(javaType.getPackage()); String targetNameSpace = resolveSchemaNamespace(packageName); XmlSchema xmlSchema = getXmlSchema(targetNameSpace); String targetNamespacePrefix = targetNamespacePrefixMap.get(targetNameSpace); if (targetNamespacePrefix == null) { targetNamespacePrefix = generatePrefix(); targetNamespacePrefixMap.put(targetNameSpace, targetNamespacePrefix); } XmlSchemaComplexType complexType = new XmlSchemaComplexType(xmlSchema); XmlSchemaSequence sequence = new XmlSchemaSequence(); XmlSchemaComplexContentExtension complexExtension = new XmlSchemaComplexContentExtension(); XmlSchemaElement eltOuter = new XmlSchemaElement(); schemaTypeName = new QName(targetNameSpace, simpleName, targetNamespacePrefix); eltOuter.setName(simpleName); eltOuter.setQName(schemaTypeName); Class<?> sup = javaType.getSuperclass(); if ((sup != null) && (!"java.lang.Object".equals(sup.getName())) && (!"java.lang.Exception".equals(sup.getName())) && !getQualifiedName(sup.getPackage()).startsWith("org.apache.axis2") && !getQualifiedName(sup.getPackage()).startsWith("java.util")) { String superClassName = sup.getName(); String superclassname = getSimpleClassName(sup); String tgtNamespace; String tgtNamespacepfx; QName qName = typeTable.getSimpleSchemaTypeName(superClassName); if (qName != null) { tgtNamespace = qName.getNamespaceURI(); tgtNamespacepfx = qName.getPrefix(); } else { tgtNamespace = resolveSchemaNamespace(getQualifiedName(sup.getPackage())); tgtNamespacepfx = targetNamespacePrefixMap.get(tgtNamespace); QName superClassQname = generateSchema(sup); if (superClassQname != null) { tgtNamespacepfx = superClassQname.getPrefix(); tgtNamespace = superClassQname.getNamespaceURI(); } } if (tgtNamespacepfx == null) { tgtNamespacepfx = generatePrefix(); targetNamespacePrefixMap.put(tgtNamespace, tgtNamespacepfx); } //if the parent class package name is differ from the child if (!((NamespaceMap) xmlSchema.getNamespaceContext()).values().contains(tgtNamespace)) { XmlSchemaImport importElement = new XmlSchemaImport(); importElement.setNamespace(tgtNamespace); xmlSchema.getItems().add(importElement); ((NamespaceMap) xmlSchema.getNamespaceContext()).put(generatePrefix(), tgtNamespace); } QName basetype = new QName(tgtNamespace, superclassname, tgtNamespacepfx); complexExtension.setBaseTypeName(basetype); complexExtension.setParticle(sequence); XmlSchemaComplexContent contentModel = new XmlSchemaComplexContent(); contentModel.setContent(complexExtension); complexType.setContentModel(contentModel); } else { complexType.setParticle(sequence); } complexType.setName(simpleName); if (Modifier.isAbstract(javaType.getModifiers())) { complexType.setAbstract(true); } // xmlSchema.getItems().add(eltOuter); xmlSchema.getElements().add(schemaTypeName, eltOuter); eltOuter.setSchemaTypeName(complexType.getQName()); xmlSchema.getItems().add(complexType); xmlSchema.getSchemaTypes().add(schemaTypeName, complexType); // adding this type to the table typeTable.addComplexSchema(name, eltOuter.getQName()); // adding this type's package to the table, to support inheritance. typeTable.addComplexSchema(getQualifiedName(javaType.getPackage()), eltOuter.getQName()); typeTable.addClassNameForQName(eltOuter.getQName(), name); BeanExcludeInfo beanExcludeInfo = null; if (service.getExcludeInfo() != null) { beanExcludeInfo = service.getExcludeInfo().getBeanExcludeInfoForClass(getClassName(javaType)); } // we need to get properties only for this bean. hence ignore the super // class properties BeanInfo beanInfo = Introspector.getBeanInfo(javaType, javaType.getSuperclass()); for (PropertyDescriptor property : beanInfo.getPropertyDescriptors()) { String propertyName = property.getName(); if (!property.getName().equals("class") && (property.getPropertyType() != null)) { if ((beanExcludeInfo == null) || !beanExcludeInfo.isExcludedProperty(propertyName)) { Type genericFieldType = null; try { Field field = javaType.getDeclaredField(propertyName); genericFieldType = field.getGenericType(); } catch (Exception e) { //log.info(e.getMessage()); } if (genericFieldType instanceof ParameterizedType) { ParameterizedType aType = (ParameterizedType) genericFieldType; Type[] fieldArgTypes = aType.getActualTypeArguments(); try { generateSchemaforGenericFields(xmlSchema, sequence, fieldArgTypes[0], propertyName); } catch (Exception e) { generateSchemaforFieldsandProperties(xmlSchema, sequence, property.getPropertyType(), propertyName, property.getPropertyType().isArray()); } } else { generateSchemaforFieldsandProperties(xmlSchema, sequence, property.getPropertyType(), propertyName, property.getPropertyType().isArray()); } } } } } return schemaTypeName; }