List of usage examples for javax.xml.namespace QName getLocalPart
public String getLocalPart()
Get the local part of this QName
.
From source file:org.cleverbus.test.route.TestWsUriBuilder.java
@Override public String getInWsUri(QName qName, String endpointMappingRef, @Nullable String params) { Assert.notNull(qName, "the qName must not be null"); Assert.hasText(qName.getLocalPart(), "the localPart must not be empty"); return URI_WS_IN + qName.getLocalPart(); }
From source file:microsoft.exchange.webservices.data.core.EwsXmlReader.java
/** * Check end element./*from w w w. j a v a 2s . c om*/ * * @param startEvent the start event * @param endEvent the end event * @return true, if successful */ public static boolean checkEndElement(XMLEvent startEvent, XMLEvent endEvent) { boolean isEndElement = false; if (endEvent.isEndElement()) { QName qEName = endEvent.asEndElement().getName(); QName qSName = startEvent.asStartElement().getName(); isEndElement = qEName.getLocalPart().equals(qSName.getLocalPart()) && (qEName.getPrefix().equals(qSName.getPrefix()) || qEName.getNamespaceURI().equals(qSName.getNamespaceURI())); } return isEndElement; }
From source file:com.evolveum.midpoint.web.component.wizard.WizardStep.java
protected IValidator<String> createObjectClassValidator(final IModel<List<QName>> model) { return new IValidator<String>() { @Override/*ww w . j ava 2 s . com*/ public void validate(IValidatable<String> validated) { String value = validated.getValue(); List<QName> list = model.getObject(); List<String> stringList = new ArrayList<>(); for (QName q : list) { stringList.add(q.getLocalPart()); } if (!stringList.contains(value)) { error(createStringResource("SchemaHandlingStep.message.validationError", value).getString()); AjaxRequestTarget target = getRequestCycle().find(AjaxRequestTarget.class); target.add(getPageBase().getFeedbackPanel()); } } }; }
From source file:org.castor.jaxb.CastorJAXBIntrospectorTest.java
/** * Tests the {@link JAXBIntrospector#getElementName(Object)} method. * * @throws Exception/*from www . j a v a2 s.c o m*/ * if any error occurs during test */ @Test public void testGetElementName() throws Exception { QName name = introspector.getElementName(new Entity()); assertEquals("Element has invalid name.", "Entity", name.getLocalPart()); }
From source file:StAXEventTreeViewer.java
public void buildTree(DefaultTreeModel treeModel, DefaultMutableTreeNode current, File file) throws XMLStreamException, FileNotFoundException { XMLInputFactory inputFactory = XMLInputFactory.newInstance(); XMLEventReader reader = inputFactory.createXMLEventReader(new FileInputStream(file)); while (reader.hasNext()) { XMLEvent event = reader.nextEvent(); switch (event.getEventType()) { case XMLStreamConstants.START_DOCUMENT: StartDocument startDocument = (StartDocument) event; DefaultMutableTreeNode version = new DefaultMutableTreeNode(startDocument.getVersion()); current.add(version);/*from w ww. j av a2 s. c om*/ current.add(new DefaultMutableTreeNode(startDocument.isStandalone())); current.add(new DefaultMutableTreeNode(startDocument.standaloneSet())); current.add(new DefaultMutableTreeNode(startDocument.encodingSet())); current.add(new DefaultMutableTreeNode(startDocument.getCharacterEncodingScheme())); break; case XMLStreamConstants.START_ELEMENT: StartElement startElement = (StartElement) event; QName elementName = startElement.getName(); DefaultMutableTreeNode element = new DefaultMutableTreeNode(elementName.getLocalPart()); current.add(element); current = element; if (!elementName.getNamespaceURI().equals("")) { String prefix = elementName.getPrefix(); if (prefix.equals("")) { prefix = "[None]"; } DefaultMutableTreeNode namespace = new DefaultMutableTreeNode( "prefix=" + prefix + ",URI=" + elementName.getNamespaceURI()); current.add(namespace); } for (Iterator it = startElement.getAttributes(); it.hasNext();) { Attribute attr = (Attribute) it.next(); DefaultMutableTreeNode attribute = new DefaultMutableTreeNode("Attribute (name=" + attr.getName().getLocalPart() + ",value=" + attr.getValue() + "')"); String attURI = attr.getName().getNamespaceURI(); if (!attURI.equals("")) { String attPrefix = attr.getName().getPrefix(); if (attPrefix.equals("")) { attPrefix = "[None]"; } attribute.add(new DefaultMutableTreeNode("prefix = " + attPrefix + ", URI = " + attURI)); } current.add(attribute); } break; case XMLStreamConstants.END_ELEMENT: current = (DefaultMutableTreeNode) current.getParent(); break; case XMLStreamConstants.CHARACTERS: Characters characters = (Characters) event; if (!characters.isIgnorableWhiteSpace() && !characters.isWhiteSpace()) { String data = characters.getData(); if (data.length() != 0) { current.add(new DefaultMutableTreeNode(characters.getData())); } } break; case XMLStreamConstants.DTD: DTD dtde = (DTD) event; current.add(new DefaultMutableTreeNode(dtde.getDocumentTypeDeclaration())); default: System.out.println(event.getClass().getName()); } } }
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.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); }/*from w w w. j a va2 s . c om*/ } } 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:com.wavemaker.tools.ws.WebServiceToolsManager.java
/** * Returns a list of XML qualified names of the elements defined in the schema. */// ww w. j ava 2 s .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.evolveum.midpoint.prism.xml.XmlTypeConverter.java
/** * @param val/* www . jav a 2 s . c om*/ * @param elementName * @param doc * @param recordType * @return created element * @throws JAXBException */ public static Object toXsdElement(Object val, QName elementName, Document doc, boolean recordType) throws SchemaException { if (val == null) { // if no value is specified, do not create element return null; } Class type = XsdTypeMapper.getTypeFromClass(val.getClass()); if (type == null) { throw new IllegalArgumentException( "No type mapping for conversion: " + val.getClass() + "(element " + elementName + ")"); } if (doc == null) { doc = DOMUtil.getDocument(); } Element element = doc.createElementNS(elementName.getNamespaceURI(), elementName.getLocalPart()); //TODO: switch to global namespace prefixes map // element.setPrefix(MidPointNamespacePrefixMapper.getPreferredPrefix(elementName.getNamespaceURI())); toXsdElement(val, element, recordType); return element; }
From source file:com.evolveum.midpoint.gui.api.component.autocomplete.AutoCompleteQNamePanel.java
private Map<String, QName> getChoiceMap() { if (choiceMap == null) { Collection<QName> choices = loadChoices(); choiceMap = new HashMap<>(); for (QName choice : choices) { // TODO: smarter initialization of the map choiceMap.put(choice.getLocalPart(), choice); }/*w w w .java2s.c o m*/ } return choiceMap; }