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.wso2.carbon.identity.entitlement.wsxacml.WSXACMLMessageReceiver.java
/** * Create XMLObject from a given QName//from w w w . j a v a 2s. co m * * @param objectQName: QName of the object to be built into a XMLObject * @return built xmlObject * @throws EntitlementException */ private static XMLObject buildXMLObject(QName objectQName) throws EntitlementException { XMLObjectBuilder builder = org.opensaml.xml.Configuration.getBuilderFactory().getBuilder(objectQName); if (builder == null) { throw new EntitlementException("Unable to retrieve builder for object QName " + objectQName); } return builder.buildObject(objectQName.getNamespaceURI(), objectQName.getLocalPart(), objectQName.getPrefix()); }
From source file:org.wso2.carbon.identity.provider.saml.SAML1TokenBuilder.java
protected static XMLObject buildXMLObject(QName objectQName) throws IdentityProviderException { XMLObjectBuilder builder = Configuration.getBuilderFactory().getBuilder(objectQName); if (builder == null) { throw new IdentityProviderException("Unable to retrieve builder for object QName " + objectQName); }//from w w w . jav a 2s . com return builder.buildObject(objectQName.getNamespaceURI(), objectQName.getLocalPart(), objectQName.getPrefix()); }
From source file:org.wso2.carbon.identity.sso.saml.SAMLTestRequestBuilder.java
private static XMLObject buildXMLObject(QName objectQName) { XMLObjectBuilder builder = org.opensaml.xml.Configuration.getBuilderFactory().getBuilder(objectQName); return builder.buildObject(objectQName.getNamespaceURI(), objectQName.getLocalPart(), objectQName.getPrefix()); }
From source file:org.wso2.carbon.rule.ws.ui.ns.NameSpacesRegistrar.java
public void registerNameSpaces(QName qName, String id, String owner, HttpSession httpSession) { if (qName == null) { if (log.isDebugEnabled()) { log.debug("Provide QName is null. returning without registering NameSpaces"); }/*from ww w . j ava 2s . c o m*/ return; } NameSpacesInformationRepository repository = getNameSpacesInformationRepository(httpSession); NameSpacesInformation information = getNameSpacesInformation(owner, id, repository); addNameSpace(qName.getPrefix(), qName.getNamespaceURI(), information); logOnSuccess(information, id); }
From source file:org.wso2.carbon.sequences.ui.util.ns.NameSpacesRegistrar.java
public void registerNameSpaces(QName qName, String id, HttpSession httpSession) { if (qName == null) { if (log.isDebugEnabled()) { log.debug("Provide QName is null. returning without registering NameSpaces"); }/*from w ww . j a v a 2 s . com*/ return; } NameSpacesInformationRepository repository = getNameSpacesInformationRepository(httpSession); NameSpacesInformation information = getNameSpacesInformation( SequenceEditorHelper.getEditingMediatorPosition(httpSession), id, repository); addNameSpace(qName.getPrefix(), qName.getNamespaceURI(), information); logOnSuccess(information, id); }
From source file:org.wso2.developerstudio.datamapper.diagram.schemagen.util.SchemaGeneratorForXML.java
private OMElement traverseChildrenAndReplaceAttributes(OMElement element, OMFactory factory) { Iterator attributeIterator = element.getAllAttributes(); List<OMAttribute> removeList = new ArrayList<OMAttribute>(); List<OMElement> addList = new ArrayList<OMElement>(); String modifiedElementName = null; while (attributeIterator.hasNext()) { OMAttribute atttrib = (OMAttribute) attributeIterator.next(); OMElement attributeElement = null; //If the attribute is an element handler append the prefix to the name if (atttrib.getNamespace() != null) { QName qName = atttrib.getQName(); //construct a modified element name when we have xsi:type attribute in the element. if (XSI_NAMESPACE_URI.equals(qName.getNamespaceURI()) && XSI_TYPE.equals(qName.getLocalPart())) { modifiedElementName = element.getQName().getLocalPart() + "_" + DOLLLAR_AT_PREFIX + qName.getPrefix() + ":" + qName.getLocalPart() + "_" + atttrib.getAttributeValue(); }//from ww w. j a va 2 s.c o m String prefix = atttrib.getNamespace().getPrefix(); attributeElement = factory.createOMElement(AT_PREFIX + prefix + ":" + atttrib.getLocalName(), null); } else { //remove attribute and instead add a element with @ infront // eg <person age="30"></person> will be replaced by <person><@age>30</@age></person> attributeElement = factory.createOMElement(AT_PREFIX + atttrib.getLocalName(), null); } OMText attributeValue = factory.createOMText(atttrib.getAttributeValue()); attributeElement.addChild(attributeValue); // add to list and later remove addList.add(attributeElement); removeList.add(atttrib); } for (OMAttribute arttribute : removeList) { element.removeAttribute(arttribute); } if (addList.size() > 0) { //remove the inner text and replace it with <#@content></#@content> //eg <city listed="true">colombo</city> will be replaced by <city><@listed>true</@listed><#@content>colombo</#@content></city> String elementText = element.getText(); if (!elementText.isEmpty()) { element.setText(""); OMElement contentElement = factory.createOMElement("#@content", null); OMText contentValue = factory.createOMText(elementText); contentElement.addChild(contentValue); element.addChild(contentElement); } for (OMElement attrElement : addList) { element.addChild(attrElement); } } Iterator elementIterator = element.getChildren(); while (elementIterator.hasNext()) { OMNode child = (OMNode) elementIterator.next(); if (child instanceof OMElement) { traverseChildrenAndReplaceAttributes((OMElement) child, factory); } } if (modifiedElementName != null) { element.setLocalName(modifiedElementName); } return element; }
From source file:org.wso2.identity.scenarios.commons.SAML2SSOTestBase.java
private XMLObject buildXMLObject(QName objectQName) throws ConfigurationException { doBootstrap();/*from w w w. j a va2 s .c om*/ XMLObjectBuilder builder = org.opensaml.xml.Configuration.getBuilderFactory().getBuilder(objectQName); return builder.buildObject(objectQName.getNamespaceURI(), objectQName.getLocalPart(), objectQName.getPrefix()); }
From source file:org.xchain.namespaces.jsl.AbstractTemplateCommand.java
/** * Turns a QName into its prefixed string representation. *///from ww w . ja va 2 s . co m protected static final String toPrefixedQName(QName qName) { if (qName.getPrefix() == null || "".equals(qName.getPrefix())) { return qName.getLocalPart(); } else { return qName.getPrefix() + ":" + qName.getLocalPart(); } }
From source file:org.xchain.namespaces.test.FilterElement.java
public boolean execute(JXPathContext context) throws Exception { boolean result = false; QName name = getName(context); String executeChars = getExecuteChars(context); ContentHandler handler = getContentHandler(); if (name != null) { handler.startElement(name.getNamespaceURI(), name.getLocalPart(), name.getPrefix(), new AttributesImpl()); }//from w w w . j ava2s . c o m if (executeChars != null) { char[] characters = executeChars.toCharArray(); handler.characters(characters, 0, characters.length); } result = super.execute(context); return result; }
From source file:org.xchain.namespaces.test.FilterElement.java
public boolean postProcess(JXPathContext context, Exception exception) { boolean handled = false; try {/*w ww .ja v a2 s . co m*/ handled = super.postProcess(context, exception); QName name = getName(context); String postProcessChars = getPostProcessChars(context); ContentHandler handler = getContentHandler(); if (postProcessChars != null) { char[] characters = postProcessChars.toCharArray(); handler.characters(characters, 0, characters.length); } if (name != null) { handler.endElement(name.getNamespaceURI(), name.getLocalPart(), name.getPrefix()); } } catch (Exception e) { // this exception should propigate. } return handled; }