List of usage examples for javax.xml.namespace QName getNamespaceURI
public String getNamespaceURI()
Get the Namespace URI of this QName
.
From source file:com.evolveum.midpoint.prism.marshaller.XPathHolder.java
public String toCanonicalPath(Class objectType, PrismContext prismContext) { StringBuilder sb = new StringBuilder("\\"); boolean first = true; PrismObjectDefinition objDef = null; if (objectType != null) { objDef = prismContext.getSchemaRegistry().findObjectDefinitionByCompileTimeClass(objectType); }/*www . j a v a 2 s . c o m*/ ItemDefinition def = null; for (XPathSegment seg : segments) { if (seg.isIdValueFilter()) { //for now, we don't want to save concrete id, just the path continue; } else { QName qname = seg.getQName(); if (!first) { sb.append("\\"); if (StringUtils.isBlank(qname.getNamespaceURI()) && objDef != null) { if (def instanceof PrismContainerDefinition) { PrismContainerDefinition containerDef = (PrismContainerDefinition) def; def = containerDef.findItemDefinition(qname); } if (def != null) { qname = def.getName(); } } } else { if (StringUtils.isBlank(qname.getNamespaceURI()) && objDef != null) { def = objDef.findItemDefinition(qname); if (def != null) { qname = def.getName(); } } first = false; } sb.append(QNameUtil.qNameToUri(qname)); } } return sb.toString(); }
From source file:com.evolveum.midpoint.prism.marshaller.ItemPathHolder.java
public Map<String, String> getNamespaceMap() { Map<String, String> namespaceMap = new HashMap<>(); Iterator<PathHolderSegment> iter = segments.iterator(); while (iter.hasNext()) { PathHolderSegment seg = iter.next(); QName qname = seg.getQName(); if (qname != null) { if (qname.getPrefix() != null && !qname.getPrefix().isEmpty()) { namespaceMap.put(qname.getPrefix(), qname.getNamespaceURI()); }// ww w . j a v a 2s. c o m // this code seems to be currently of no use // else { // // Default namespace // // HACK. See addPureXpath method // namespaceMap.put(DEFAULT_PREFIX, qname.getNamespaceURI()); // } } } return namespaceMap; }
From source file:com.evolveum.midpoint.prism.schema.SchemaToDomProcessor.java
private void setAttribute(Element element, QName attr, QName attrValue) { if (attributeQualified) { DOMUtil.setQNameAttribute(element, attr, attrValue, rootXsdElement); addToImport(attr.getNamespaceURI()); } else {// w w w .j a va 2 s . c o m DOMUtil.setQNameAttribute(element, attr.getLocalPart(), attrValue, rootXsdElement); } }
From source file:com.googlecode.ddom.frontend.saaj.SOAPElementTest.java
@Validated @Test/* w w w . j av a 2 s .com*/ public void testCreateQNameWithAddNamespaceDeclaration() throws Exception { SOAPElement element = saajUtil.createSOAPElement("urn:ns", "test", null); element.addNamespaceDeclaration("p", "urn:test"); QName qname = element.createQName("local", "p"); assertEquals("p", qname.getPrefix()); assertEquals("local", qname.getLocalPart()); assertEquals("urn:test", qname.getNamespaceURI()); }
From source file:com.evolveum.midpoint.model.impl.validator.ResourceValidatorImpl.java
private void registerName(ResourceValidationContext ctx, Set<QName> existingNames, Set<QName> duplicates, ItemPathType ref) {/* w w w . ja va 2 s . c om*/ QName name = itemRefToName(ref); if (name != null) { if (name.getNamespaceURI() == null) { name = new QName(ResourceTypeUtil.getResourceNamespace(ctx.resourceObject), name.getLocalPart()); // TODO is this correct? } if (!existingNames.add(name)) { duplicates.add(name); } } }
From source file:com.evolveum.midpoint.prism.PrismContainerDefinitionImpl.java
@Override public <ID extends ItemDefinition> ID findNamedItemDefinition(@NotNull QName firstName, @NotNull ItemPath rest, @NotNull Class<ID> clazz) { // we need to be compatible with older versions..soo if the path does // not contains qnames with namespaces defined (but the prefix was // specified) match definition according to the local name if (StringUtils.isEmpty(firstName.getNamespaceURI())) { for (ItemDefinition def : getDefinitions()) { if (QNameUtil.match(firstName, def.getName())) { return (ID) def.findItemDefinition(rest, clazz); }/*ww w . j av a 2 s. co m*/ } } for (ItemDefinition def : getDefinitions()) { if (firstName.equals(def.getName())) { return (ID) def.findItemDefinition(rest, clazz); } } // if (isRuntimeSchema()) { // return findRuntimeItemDefinition(firstName, rest, clazz); // } return null; }
From source file:com.evolveum.midpoint.prism.util.JaxbTestUtil.java
public boolean canConvert(QName xsdType) { SchemaDescription schemaDesc = getSchemaRegistry() .findSchemaDescriptionByNamespace(xsdType.getNamespaceURI()); if (schemaDesc == null) { return false; }// w w w .j a v a 2s. c o m if (schemaDesc.getCompileTimeClassesPackage() == null) { return false; } // We may be answering "yes" to a broader set of types that we can really convert. // But that does not matter that much. If the type is in the correct namespace // then either we can convert it or nobody can. return true; // Following code is not really correct. There are XSD types that we can convert and there is // no complexTypeDefinition for then in our parsed schema. E.g. all the property JAXB types. // ComplexTypeDefinition complexTypeDefinition = schema.findComplexTypeDefinition(xsdType); // return complexTypeDefinition != null; }
From source file:com.evolveum.midpoint.prism.parser.XPathHolder.java
private void addPureXpath(StringBuilder sb) { if (!absolute && segments.isEmpty()) { // Empty segment list gives a "local node" XPath sb.append("."); return;/*ww w. jav a 2s .c o m*/ } if (absolute) { sb.append("/"); } boolean first = true; for (XPathSegment seg : segments) { if (seg.isIdValueFilter()) { sb.append("["); sb.append(seg.getValue()); sb.append("]"); } else { if (!first) { sb.append("/"); } else { first = false; } if (seg.isVariable()) { sb.append("$"); } QName qname = seg.getQName(); if (!StringUtils.isEmpty(qname.getPrefix())) { sb.append(qname.getPrefix() + ":" + qname.getLocalPart()); } else { if (StringUtils.isNotEmpty(qname.getNamespaceURI())) { String prefix = GlobalDynamicNamespacePrefixMapper .getPreferredPrefix(qname.getNamespaceURI()); seg.setQNamePrefix(prefix); // hack - we modify the path segment here (only the form, not the meaning), but nevertheless it's ugly sb.append(seg.getQName().getPrefix() + ":" + seg.getQName().getLocalPart()); } else { // no namespace, no prefix sb.append(qname.getLocalPart()); } } } } }
From source file:com.evolveum.midpoint.prism.marshaller.XPathHolder.java
public Map<String, String> getNamespaceMap() { Map<String, String> namespaceMap = new HashMap<String, String>(); Iterator<XPathSegment> iter = segments.iterator(); while (iter.hasNext()) { XPathSegment seg = iter.next();//w ww. j ava 2 s.c om QName qname = seg.getQName(); if (qname != null) { if (qname.getPrefix() != null && !qname.getPrefix().isEmpty()) { namespaceMap.put(qname.getPrefix(), qname.getNamespaceURI()); } // this code seems to be currently of no use // else { // // Default namespace // // HACK. See addPureXpath method // namespaceMap.put(DEFAULT_PREFIX, qname.getNamespaceURI()); // } } } return namespaceMap; }
From source file:com.evolveum.midpoint.prism.schema.SchemaToDomProcessor.java
/** * Set attribute in the DOM element to a QName value. This will make sure that the * appropriate namespace definition for the QName exists. * //from ww w. ja va 2s. co m * @param element element element element where to set attribute * @param attrName attribute name (String) * @param value attribute value (Qname) */ private void setQNameAttribute(Element element, String attrName, QName value) { QName valueWithPrefix = namespacePrefixMapper.setQNamePrefix(value); DOMUtil.setQNameAttribute(element, attrName, valueWithPrefix, rootXsdElement); addToImport(value.getNamespaceURI()); }