String getNamespaceURI(String prefix) { if (currentEvent == START_ELEMENT || currentEvent == END_ELEMENT) { if (node instanceof OMElement) { OMNamespace namespaceURI = ((OMElement) node).findNamespaceURI(prefix); return namespaceURI != null ? namespaceURI.getNamespaceURI() : null; } } return null; }
String getNamespaceURI(String prefix) { if (currentEvent == START_ELEMENT || currentEvent == END_ELEMENT) { if (node instanceof OMElement) { OMNamespace namespaceURI = ((OMElement) node).findNamespaceURI(prefix); return namespaceURI != null ? namespaceURI.getNamespaceURI() : null; } } return null; }
public OMNamespace findNamespaceURI(String prefix) { OMNamespace ns = this.namespaces == null ? null : (OMNamespace) this.namespaces.get(prefix); if (ns == null && this.parentNode instanceof OMElement) { // try with the parent ns = ((OMElement) this.parentNode).findNamespaceURI(prefix); } return ns; }
protected String doGetNamespaceURI(String prefix) { OMNamespace ns = element.findNamespaceURI(prefix); return ns == null ? XMLConstants.NULL_NS_URI : ns.getNamespaceURI(); }
public String getNamespaceURI(String prefix) { OMNamespace ns = omTarget.findNamespaceURI(prefix); return ns != null ? ns.getNamespaceURI() : null; }
protected String doGetNamespaceURI(String prefix) { OMNamespace ns = element.findNamespaceURI(prefix); return ns == null ? XMLConstants.NULL_NS_URI : ns.getNamespaceURI(); }
protected String doGetNamespaceURI(String prefix) { OMNamespace ns = element.findNamespaceURI(prefix); return ns == null ? XMLConstants.NULL_NS_URI : ns.getNamespaceURI(); }
public String getNamespaceURI(String prefix) { OMNamespace ns = omTarget.findNamespaceURI(prefix); return ns != null ? ns.getNamespaceURI() : null; }
private OMNamespace getOMNamespace(String prefix, String namespaceURI, boolean isDecl) { if (prefix == null) { prefix = ""; } if (namespaceURI == null) { namespaceURI = ""; } if (!isDecl && namespaceURI.length() == 0) { return null; } else { if (parent != null) { // If possible, locate an existing OMNamespace object OMNamespace ns = parent.findNamespaceURI(prefix); if (ns != null && ns.getNamespaceURI().equals(namespaceURI)) { return ns; } } return factory.createOMNamespace(namespaceURI, prefix); } }
private OMNamespace getOMNamespace(String prefix, String namespaceURI, boolean isDecl) { if (prefix == null) { prefix = ""; } if (namespaceURI == null) { namespaceURI = ""; } if (!isDecl && namespaceURI.length() == 0) { return null; } else { if (parent != null) { // If possible, locate an existing OMNamespace object OMNamespace ns = parent.findNamespaceURI(prefix); if (ns != null && ns.getNamespaceURI().equals(namespaceURI)) { return ns; } } return factory.createOMNamespace(namespaceURI, prefix); } }
/** * Axiom is supposed to handle this properly however this method is buggy and doesn't work (whereas setting a QName as text * works). * * @param elmt * @return text qname */ public static QName getTextAsQName(OMElement elmt) { QName qname = elmt.getTextAsQName(); // The getTextAsQName is buggy, it sometimes return the full text without extracting namespace if (qname == null || qname.getNamespaceURI().length() == 0) { int colonIdx = elmt.getText().indexOf(":"); String localpart = elmt.getText().substring(colonIdx + 1, elmt.getText().length()); String prefix = elmt.getText().substring(0, colonIdx); String ns = elmt.findNamespaceURI(prefix).getNamespaceURI(); qname = new QName(ns, localpart, prefix); } return qname; }
private void processAttribute(String prefix, String namespaceURI, String localName, String type, String value) throws OutputException { mapNamespace(prefix, namespaceURI, false, true); if (namespaceRepairing && contextElement != null && namespaceURI.equals(XSI_URI) && localName.equals(XSI_LOCAL_NAME)) { String trimmedValue = value.trim(); if (trimmedValue.indexOf(":") > 0) { String refPrefix = trimmedValue.substring(0, trimmedValue.indexOf(":")); OMNamespace ns = contextElement.findNamespaceURI(refPrefix); if (ns != null) { mapNamespace(refPrefix, ns.getNamespaceURI(), false, true); } } } addAttribute(prefix, namespaceURI, localName, type, value); }
private void processAttribute(String prefix, String namespaceURI, String localName, String type, String value) throws OutputException { mapNamespace(prefix, namespaceURI, false, true); if (namespaceRepairing && contextElement != null && namespaceURI.equals(XSI_URI) && localName.equals(XSI_LOCAL_NAME)) { String trimmedValue = value.trim(); if (trimmedValue.indexOf(":") > 0) { String refPrefix = trimmedValue.substring(0, trimmedValue.indexOf(":")); OMNamespace ns = contextElement.findNamespaceURI(refPrefix); if (ns != null) { mapNamespace(refPrefix, ns.getNamespaceURI(), false, true); } } } addAttribute(prefix, namespaceURI, localName, type, value); }
protected QName doGetQName(String prefixedValue) throws WSDLException { OMElement elem = (OMElement)fSource; int index = prefixedValue.indexOf(':'); String prefix = (index != -1) ? prefixedValue.substring(0, index) : null; String localPart = prefixedValue.substring(index + 1); OMNamespace OMns = elem.findNamespaceURI(prefix); String namespaceURI = OMns != null ? OMns.getNamespaceURI() : null; if(prefix != null && namespaceURI == null) { String faultCode = WSDLException.UNBOUND_PREFIX; String msg = fErrorReporter.getFormattedMessage( "WSDL513", new Object[] {prefixedValue, elem.getQName()}); WSDLException wsdlExc = new WSDLException( faultCode, msg); //TODO wsdlExc.setLocation(XPathUtils.getXPathExprFromNode(el)); throw wsdlExc; } return new QName(namespaceURI, localPart, (prefix != null ? prefix : emptyString)); }
public static void setNamespace(OMElement element, String namespaceURI, String prefix, boolean namespaceURIInterning) { if (prefix == null) { prefix = ""; } if (namespaceURI == null) { namespaceURI = ""; } // Check if there is an existing namespace declaration. This has two purposes: // * Avoid creating a new OMNamespace instance for each OMElement // * Perform namespace repairing OMNamespace namespace = element.findNamespaceURI(prefix); if (namespace == null && namespaceURI.length() > 0 || namespace != null && !namespace.getNamespaceURI().equals(namespaceURI)) { if (namespaceURIInterning) { namespaceURI = namespaceURI.intern(); } // This is actually the place where we perform namespace repairing as specified // in the contract of OMXMLBuilderFactory#createStAXOMBuilder: namespace = ((OMElementEx)element).addNamespaceDeclaration(namespaceURI, prefix); } if (namespace != null && namespaceURI.length() > 0) { element.setNamespace(namespace, false); } } }
/** * Method getNamespaceURI. * * @param prefix * @return Returns String. */ public String getNamespaceURI(String prefix) { String returnString = null; if (parser != null) { returnString = parser.getNamespaceURI(prefix); } else { if (isStartElement() || isEndElement()) { if (lastNode instanceof OMElement) { OMNamespace namespaceURI = ((OMElement) lastNode).findNamespaceURI(prefix); return namespaceURI != null ? namespaceURI.getNamespaceURI() : null; } } } return returnString; }
/** * {@inheritDoc} */ @Override public String getAttribute(String localName, String namespace, String prefix) { if (nodeType != XMLNodeType.ELEMENT || localName == null || localName.isEmpty()) { return STRING_NULL_VALUE; } QName attributeName = getQName(localName, namespace, prefix); OMAttribute attribute = ((OMElement) omNode).getAttribute(attributeName); if (attribute != null) { return attribute.getAttributeValue(); } OMNamespace ns = ((OMElement) omNode).findNamespaceURI(localName); return ns == null ? STRING_NULL_VALUE : ns.getNamespaceURI(); }
OMNamespace namespace = element.findNamespaceURI(prefix); if (namespace == null) { return null;
OMNamespace attrValNs = element.findNamespaceURI(attr.getAttributeValue().substring(0, colonIdx)); if (attrValNs != null) domElement.setAttributeNS(DOMUtils.NS_URI_XMLNS, "xmlns:"+ attrValNs.getPrefix(), attrValNs.getNamespaceURI());
OMNamespace existingNs = node.findNamespaceURI(prefix);