List of usage examples for javax.xml.namespace QName getNamespaceURI
public String getNamespaceURI()
Get the Namespace URI of this QName
.
From source file:org.eclipse.winery.repository.client.WineryRepositoryClient.java
private static WebResource getTopologyTemplateWebResource(WebResource base, QName serviceTemplate) { String nsEncoded = Util.DoubleURLencode(serviceTemplate.getNamespaceURI()); String idEncoded = Util.DoubleURLencode(serviceTemplate.getLocalPart()); WebResource res = base.path("servicetemplates").path(nsEncoded).path(idEncoded).path("topologytemplate"); return res;/* w ww . j a v a 2 s .c om*/ }
From source file:com.evolveum.midpoint.model.impl.validator.ResourceValidatorImpl.java
public static String prettyPrintUsingStandardPrefix(QName name) { if (name == null) { return null; }//from www.ja va 2s .com String ns = name.getNamespaceURI(); if (SchemaConstants.NS_C.equals(ns)) { return "c:" + name.getLocalPart(); } else if (MidPointConstants.NS_RI.equals(ns)) { return "ri:" + name.getLocalPart(); } else if (SchemaConstantsGenerated.NS_ICF_SCHEMA.equals(ns)) { return "icfs:" + name.getLocalPart(); } else if (SchemaConstantsGenerated.NS_ICF_SCHEMA.equals(ns)) { return "icfs:" + name.getLocalPart(); } else { return null; } }
From source file:com.xqdev.jam.MLJAM.java
private static void sendXQueryResponse(HttpServletResponse res, Object o) throws IOException { // Make sure to leave the status code alone. It defaults to 200, but sometimes // callers of this method will have set it to a custom code. res.setContentType("x-marklogic/xquery; charset=UTF-8"); //res.setContentType("text/plain"); Writer writer = res.getWriter(); // care to handle errors later? if (o == null) { writer.write("()"); }/* ww w .j a v a2 s. c o m*/ else if (o instanceof byte[]) { writer.write("binary {'"); writer.write(hexEncode((byte[]) o)); writer.write("'}"); } else if (o instanceof Object[]) { Object[] arr = (Object[]) o; writer.write("("); for (int i = 0; i < arr.length; i++) { sendXQueryResponse(res, arr[i]); if (i + 1 < arr.length) writer.write(", "); } writer.write(")"); } else if (o instanceof String) { writer.write("'"); writer.write(escapeSingleQuotes(o.toString())); writer.write("'"); } else if (o instanceof Integer) { writer.write("xs:int("); writer.write(o.toString()); writer.write(")"); } else if (o instanceof Long) { writer.write("xs:integer("); writer.write(o.toString()); writer.write(")"); } else if (o instanceof Float) { Float flt = (Float) o; writer.write("xs:float("); if (flt.equals(Float.POSITIVE_INFINITY)) { writer.write("'INF'"); } else if (flt.equals(Float.NEGATIVE_INFINITY)) { writer.write("'-INF'"); } else if (flt.equals(Float.NaN)) { writer.write("fn:number(())"); // poor man's way to write NaN } else { writer.write(o.toString()); } writer.write(")"); } else if (o instanceof Double) { Double dbl = (Double) o; writer.write("xs:double("); if (dbl.equals(Double.POSITIVE_INFINITY)) { writer.write("'INF'"); } else if (dbl.equals(Double.NEGATIVE_INFINITY)) { writer.write("'-INF'"); } else if (dbl.equals(Double.NaN)) { writer.write("fn:number(())"); // poor man's way to write NaN } else { writer.write(o.toString()); } writer.write(")"); } else if (o instanceof Boolean) { writer.write("xs:boolean('"); writer.write(o.toString()); writer.write("')"); } else if (o instanceof BigDecimal) { writer.write("xs:decimal("); writer.write(o.toString()); writer.write(")"); } else if (o instanceof Date) { // We want something like: 2006-04-30T01:28:30.499-07:00 // We format to get: 2006-04-30T01:28:30.499-0700 // Then we add in the colon writer.write("xs:dateTime('"); String d = dateFormat.format((Date) o); writer.write(d.substring(0, d.length() - 2)); writer.write(":"); writer.write(d.substring(d.length() - 2)); writer.write("')"); } else if (o instanceof XMLGregorianCalendar) { XMLGregorianCalendar greg = (XMLGregorianCalendar) o; QName type = greg.getXMLSchemaType(); if (type.equals(DatatypeConstants.DATETIME)) { writer.write("xs:dateTime('"); } else if (type.equals(DatatypeConstants.DATE)) { writer.write("xs:date('"); } else if (type.equals(DatatypeConstants.TIME)) { writer.write("xs:time('"); } else if (type.equals(DatatypeConstants.GYEARMONTH)) { writer.write("xs:gYearMonth('"); } else if (type.equals(DatatypeConstants.GMONTHDAY)) { writer.write("xs:gMonthDay('"); } else if (type.equals(DatatypeConstants.GYEAR)) { writer.write("xs:gYear('"); } else if (type.equals(DatatypeConstants.GMONTH)) { writer.write("xs:gMonth('"); } else if (type.equals(DatatypeConstants.GDAY)) { writer.write("xs:gDay('"); } writer.write(greg.toXMLFormat()); writer.write("')"); } else if (o instanceof Duration) { Duration dur = (Duration) o; /* // The following fails on Xerces QName type = dur.getXMLSchemaType(); if (type.equals(DatatypeConstants.DURATION)) { writer.write("xs:duration('"); } else if (type.equals(DatatypeConstants.DURATION_DAYTIME)) { writer.write("xdt:dayTimeDuration('"); } else if (type.equals(DatatypeConstants.DURATION_YEARMONTH)) { writer.write("xdt:yearMonthDuration('"); } */ // If no years or months, must be DURATION_DAYTIME if (dur.getYears() == 0 && dur.getMonths() == 0) { writer.write("xdt:dayTimeDuration('"); } // If has years or months but nothing else, must be DURATION_YEARMONTH else if (dur.getDays() == 0 && dur.getHours() == 0 && dur.getMinutes() == 0 && dur.getSeconds() == 0) { writer.write("xdt:yearMonthDuration('"); } else { writer.write("xs:duration('"); } writer.write(dur.toString()); writer.write("')"); } else if (o instanceof org.jdom.Element) { org.jdom.Element elt = (org.jdom.Element) o; writer.write("xdmp:unquote('"); // Because "<" in XQuery is the same as "<" I need to double escape any ampersands writer.write(new org.jdom.output.XMLOutputter().outputString(elt).replaceAll("&", "&") .replaceAll("'", "''")); writer.write("')/*"); // make sure to return the root elt } else if (o instanceof org.jdom.Document) { org.jdom.Document doc = (org.jdom.Document) o; writer.write("xdmp:unquote('"); writer.write(new org.jdom.output.XMLOutputter().outputString(doc).replaceAll("&", "&") .replaceAll("'", "''")); writer.write("')"); } else if (o instanceof org.jdom.Text) { org.jdom.Text text = (org.jdom.Text) o; writer.write("text {'"); writer.write(escapeSingleQuotes(text.getText())); writer.write("'}"); } else if (o instanceof org.jdom.Attribute) { // <fake xmlns:pref="http://uri.com" pref:attrname="attrvalue"/>/@*:attrname // <fake xmlns="http://uri.com" attrname="attrvalue"/>/@*:attrname org.jdom.Attribute attr = (org.jdom.Attribute) o; writer.write("<fake xmlns"); if ("".equals(attr.getNamespacePrefix())) { writer.write("=\""); } else { writer.write(":" + attr.getNamespacePrefix() + "=\""); } writer.write(attr.getNamespaceURI()); writer.write("\" "); writer.write(attr.getQualifiedName()); writer.write("=\""); writer.write(escapeSingleQuotes(attr.getValue())); writer.write("\"/>/@*:"); writer.write(attr.getName()); } else if (o instanceof org.jdom.Comment) { org.jdom.Comment com = (org.jdom.Comment) o; writer.write("comment {'"); writer.write(escapeSingleQuotes(com.getText())); writer.write("'}"); } else if (o instanceof org.jdom.ProcessingInstruction) { org.jdom.ProcessingInstruction pi = (org.jdom.ProcessingInstruction) o; writer.write("processing-instruction "); writer.write(pi.getTarget()); writer.write(" {'"); writer.write(escapeSingleQuotes(pi.getData())); writer.write("'}"); } else if (o instanceof QName) { QName q = (QName) o; writer.write("fn:expanded-QName('"); writer.write(escapeSingleQuotes(q.getNamespaceURI())); writer.write("','"); writer.write(q.getLocalPart()); writer.write("')"); } else { writer.write("error('XQuery tried to retrieve unsupported type: " + o.getClass().getName() + "')"); } writer.flush(); }
From source file:com.evolveum.midpoint.test.IntegrationTestTools.java
public static void assertNotEmpty(QName qname) { assertNotNull(qname);/*w ww . jav a 2 s. co m*/ assertNotEmpty(qname.getNamespaceURI()); assertNotEmpty(qname.getLocalPart()); }
From source file:com.evolveum.midpoint.test.IntegrationTestTools.java
public static void assertNotEmpty(String message, QName qname) { assertNotNull(message, qname);//from ww w . j a v a2 s.co m assertNotEmpty(message, qname.getNamespaceURI()); assertNotEmpty(message, qname.getLocalPart()); }
From source file:com.wavemaker.tools.ws.WebServiceToolsManager.java
/** * Returns a list of XML qualified names of the elements defined in the schema. *//*from w ww . j a v a2s. c o m*/ private static List<String> getAllSchemaElements(XmlSchema xmlSchema) { List<String> types = new ArrayList<String>(); XmlSchemaObjectTable elements = xmlSchema.getElements(); Iterator<QName> iter = CastUtils.cast(elements.getNames()); while (iter.hasNext()) { QName next = iter.next(); String namespaceURI = next.getNamespaceURI(); types.add((namespaceURI == null || namespaceURI.length() == 0 ? "" : namespaceURI + ":") + next.getLocalPart()); } return types; }
From source file:com.twinsoft.convertigo.engine.migration.Migration7_0_0.java
private static void handleSteps(XmlSchema projectSchema, Map<String, Reference> referenceMap, List<Step> stepList) { for (Step step : stepList) { if (step instanceof XMLActionStep) { XMLVector<XMLVector<Object>> sourcesDefinition = ((XMLActionStep) step).getSourcesDefinition(); for (XMLVector<Object> row : sourcesDefinition) { if (row.size() > 1) { XMLVector<String> definition = GenericUtils.cast(row.get(1)); handleSourceDefinition(definition); }//w w w. j a v a 2s . co m } } if (step instanceof TransactionStep) { XMLVector<String> definition = ((TransactionStep) step).getConnectionStringDefinition(); handleSourceDefinition(definition); } if (step instanceof IStepSourceContainer) { /** Case step's xpath has not been migrated when project has been deployed ** on a 5.0 server from a Studio with an older version **/ IStepSourceContainer stepSourceContainer = (IStepSourceContainer) step; XMLVector<String> definition = stepSourceContainer.getSourceDefinition(); handleSourceDefinition(definition); } if (step instanceof IVariableContainer) { IVariableContainer variableContainer = (IVariableContainer) step; for (Variable variable : variableContainer.getVariables()) { if (variable instanceof IStepSourceContainer) { IStepSourceContainer stepSourceContainer = (IStepSourceContainer) variable; XMLVector<String> definition = stepSourceContainer.getSourceDefinition(); handleSourceDefinition(definition); } } } String targetProjectName = null; String typeLocalName = null; if (step instanceof TransactionStep) { targetProjectName = ((TransactionStep) step).getProjectName(); typeLocalName = ((TransactionStep) step).getConnectorName() + "__" + ((TransactionStep) step).getTransactionName() + "ResponseType"; } else if (step instanceof SequenceStep) { targetProjectName = ((SequenceStep) step).getProjectName(); typeLocalName = ((SequenceStep) step).getSequenceName() + "ResponseType"; } String namespaceURI = null; // Case of Requestable steps if (targetProjectName != null) { try { namespaceURI = Project.CONVERTIGO_PROJECTS_NAMESPACEURI + targetProjectName; if (!targetProjectName.equals(step.getProject().getName())) { try { namespaceURI = Engine.theApp.databaseObjectsManager .getOriginalProjectByName(targetProjectName).getTargetNamespace(); } catch (Exception e) { } // Add reference String location = "../" + targetProjectName + "/" + targetProjectName + ".xsd"; addReferenceToMap(referenceMap, namespaceURI, location); } // Set step's typeQName step.setXmlComplexTypeAffectation(new XmlQName(new QName(namespaceURI, typeLocalName))); } catch (Exception e) { e.printStackTrace(); } } // Other steps else { try { String targetNamespace = projectSchema.getTargetNamespace(); String targetPrefix = projectSchema.getNamespaceContext().getPrefix(targetNamespace); String s = null; try { if (step instanceof XMLCopyStep) { XmlSchemaCollection collection = SchemaMeta.getCollection(projectSchema); XmlSchemaObject ob = step.getXmlSchemaObject(collection, projectSchema); if (ob != null) { if (ob instanceof XmlSchemaSequence) { ob = ((XmlSchemaSequence) ob).getItems().getItem(0); } if (ob instanceof XmlSchemaElement || ob instanceof XmlSchemaAttribute) { QName schemaTypeName = ob instanceof XmlSchemaElement ? ((XmlSchemaElement) ob).getSchemaTypeName() : ((XmlSchemaAttribute) ob).getSchemaTypeName(); String schemaTypePrefix = projectSchema.getNamespaceContext() .getPrefix(schemaTypeName.getNamespaceURI()); String schemaTypeLocalName = schemaTypeName.getLocalPart(); s = schemaTypePrefix + ":" + schemaTypeLocalName; } } } else { String schemaType = step.getSchemaDataType(); s = schemaType.equals("") ? "xsd:string" : schemaType; } } catch (Exception e) { s = "xsd:string"; } if ((s != null) && (!s.equals("")) && (!s.startsWith("xsd:"))) { String prefix = s.split(":")[0]; typeLocalName = s.split(":")[1]; if (prefix.equals(targetPrefix)) { // ignore } else { // Retrieve namespace uri namespaceURI = projectSchema.getNamespaceContext().getNamespaceURI(prefix); // Set step's typeQName QName qname = new QName(namespaceURI, typeLocalName); XmlSchemaType schemaType = projectSchema.getTypeByName(qname); if (schemaType instanceof XmlSchemaComplexType) step.setXmlComplexTypeAffectation(new XmlQName(qname)); if (schemaType instanceof XmlSchemaSimpleType) step.setXmlSimpleTypeAffectation(new XmlQName(qname)); } } } catch (Exception e) { } } if (step instanceof ISimpleTypeAffectation) { QName qName = XmlSchemaUtils.getSchemaDataTypeName(step.getSchemaDataType()); step.setXmlSimpleTypeAffectation(new XmlQName(qName)); } if (step instanceof StepWithExpressions) { handleSteps(projectSchema, referenceMap, ((StepWithExpressions) step).getSteps()); } } }
From source file:be.selckin.ws.util.java2php.NameManager.java
public String getPhpNamespace(QName qname) { String nsprefix = nsPrefixMap.get(qname.getNamespaceURI()); // nsprefix will be null if there is no prefix. if (nsprefix == null) { nsprefix = defineFallbackPrefix(qname.getNamespaceURI()); }//from w w w. ja v a 2 s. c o m String[] separated = nsprefix.split("\\\\"); CollectionUtils.reverseArray(separated); return StringUtils.join(separated, "\\"); }
From source file:com._4dconcept.springframework.data.marklogic.core.mapping.BasicMarklogicPersistentPropertyTest.java
@Test public void resolveQName() throws Exception { MarklogicPersistentProperty property = getPropertyFor(ImplType.class, "id"); QName qName = property.getQName(); assertThat(qName.getNamespaceURI(), CoreMatchers.is("/super/type")); assertThat(qName.getLocalPart(), CoreMatchers.is("id")); MarklogicPersistentProperty property2 = getPropertyFor(ImplType.class, "name"); QName qName2 = property2.getQName(); assertThat(qName2.getNamespaceURI(), CoreMatchers.is("/test/type")); assertThat(qName2.getLocalPart(), CoreMatchers.is("name")); }
From source file:com._4dconcept.springframework.data.marklogic.core.cts.CTSQuerySerializer.java
private String serializeQName(QName qname) { return String.format("fn:QName('%s', '%s')", qname.getNamespaceURI(), qname.getLocalPart()); }