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.jaggeryjs.modules.sso.common.util.Util.java
public static XMLObject buildXMLObject(QName objectQName) throws Exception { XMLObjectBuilder builder = org.opensaml.xml.Configuration.getBuilderFactory().getBuilder(objectQName); if (builder == null) { throw new Exception("Unable to retrieve builder for object QName " + objectQName); }//from w w w . ja va 2 s . co m return builder.buildObject(objectQName.getNamespaceURI(), objectQName.getLocalPart(), objectQName.getPrefix()); }
From source file:org.jasig.portal.layout.TransientUserLayoutXMLEventReader.java
@Override protected Deque<XMLEvent> getAdditionalEvents(XMLEvent event) { if (event.isStartElement()) { final StartElement startElement = event.asStartElement(); //All following logic requires an ID attribute, ignore any element without one final Attribute idAttribute = startElement.getAttributeByName(IUserLayoutManager.ID_ATTR_NAME); if (idAttribute == null) { return null; }//from w w w .j a v a2s .c o m //Handle adding a transient folder to the root element if (this.rootFolderId.equals(idAttribute.getValue())) { final QName name = startElement.getName(); final String namespaceURI = name.getNamespaceURI(); final String prefix = name.getPrefix(); final Deque<XMLEvent> transientEventBuffer = new LinkedList<XMLEvent>(); final Collection<Attribute> transientFolderAttributes = new LinkedList<Attribute>(); transientFolderAttributes.add( EVENT_FACTORY.createAttribute("ID", TransientUserLayoutManagerWrapper.TRANSIENT_FOLDER_ID)); transientFolderAttributes.add(EVENT_FACTORY.createAttribute("type", "regular")); transientFolderAttributes.add(EVENT_FACTORY.createAttribute("hidden", "true")); transientFolderAttributes.add(EVENT_FACTORY.createAttribute("unremovable", "true")); transientFolderAttributes.add(EVENT_FACTORY.createAttribute("immutable", "true")); transientFolderAttributes.add(EVENT_FACTORY.createAttribute("name", "Transient Folder")); final StartElement transientFolder = EVENT_FACTORY.createStartElement(prefix, namespaceURI, IUserLayoutManager.FOLDER, transientFolderAttributes.iterator(), null); transientEventBuffer.add(transientFolder); //append channel element iff subscribeId describes a transient channel, and not a regular layout channel final String subscribeId = this.userLayoutManager.getFocusedId(); if (null != subscribeId && !subscribeId.equals("") && this.userLayoutManager.isTransientChannel(subscribeId)) { IPortletDefinition chanDef = null; try { chanDef = this.userLayoutManager.getChannelDefinition(subscribeId); } catch (Exception e) { this.logger.error("Could not obtain IChannelDefinition for subscribe id: " + subscribeId, e); } if (chanDef != null) { //TODO Move IChannelDefinition/IPortletDefinition -> StAX events code somewhere reusable final Collection<Attribute> channelAttrs = new LinkedList<Attribute>(); channelAttrs.add(EVENT_FACTORY.createAttribute("ID", subscribeId)); channelAttrs.add(EVENT_FACTORY.createAttribute("typeID", Integer.toString(chanDef.getType().getId()))); channelAttrs.add(EVENT_FACTORY.createAttribute("hidden", "false")); channelAttrs.add(EVENT_FACTORY.createAttribute("unremovable", "true")); channelAttrs.add(EVENT_FACTORY.createAttribute("name", chanDef.getName())); channelAttrs.add(EVENT_FACTORY.createAttribute("description", chanDef.getDescription())); channelAttrs.add(EVENT_FACTORY.createAttribute("title", chanDef.getTitle())); channelAttrs.add(EVENT_FACTORY.createAttribute("chanID", chanDef.getPortletDefinitionId().getStringId())); channelAttrs.add(EVENT_FACTORY.createAttribute("fname", chanDef.getFName())); channelAttrs.add( EVENT_FACTORY.createAttribute("timeout", Integer.toString(chanDef.getTimeout()))); channelAttrs.add(EVENT_FACTORY.createAttribute("transient", "true")); final StartElement startChannel = EVENT_FACTORY.createStartElement(prefix, namespaceURI, IUserLayoutManager.CHANNEL, channelAttrs.iterator(), null); transientEventBuffer.offer(startChannel); // add channel parameter elements for (final IPortletDefinitionParameter parm : chanDef.getParameters()) { final Collection<Attribute> parameterAttrs = new LinkedList<Attribute>(); parameterAttrs.add(EVENT_FACTORY.createAttribute("name", parm.getName())); parameterAttrs.add(EVENT_FACTORY.createAttribute("value", parm.getValue())); final StartElement startParameter = EVENT_FACTORY.createStartElement(prefix, namespaceURI, IUserLayoutManager.PARAMETER, parameterAttrs.iterator(), null); transientEventBuffer.offer(startParameter); final EndElement endParameter = EVENT_FACTORY.createEndElement(prefix, namespaceURI, IUserLayoutManager.PARAMETER, null); transientEventBuffer.offer(endParameter); } final EndElement endChannel = EVENT_FACTORY.createEndElement(prefix, namespaceURI, IUserLayoutManager.CHANNEL, null); transientEventBuffer.offer(endChannel); } } final EndElement endFolder = EVENT_FACTORY.createEndElement(prefix, namespaceURI, IUserLayoutManager.FOLDER, null); transientEventBuffer.offer(endFolder); return transientEventBuffer; } } return null; }
From source file:org.jboss.bpm.console.server.util.DOMUtils.java
/** Create an Element for a given QName *///from w ww .java 2 s. co m public static Element createElement(QName qname) { return createElement(qname.getLocalPart(), qname.getPrefix(), qname.getNamespaceURI()); }
From source file:org.jbpm.bpel.integration.soap.SoapUtil.java
private static String formatQName(QName value, SOAPElement elem) throws SOAPException { String namespaceURI = value.getNamespaceURI(); String localName = value.getLocalPart(); // easy way out: no namespace if (namespaceURI.length() == 0) return localName; String prefix = SoapUtil.getPrefix(namespaceURI, elem); if (prefix == null) { String givenPrefix = value.getPrefix(); prefix = XmlUtil.generatePrefix(givenPrefix.length() > 0 ? givenPrefix : QUALIFIED_VALUE_PREFIX, elem); elem.addNamespaceDeclaration(prefix, namespaceURI); }/*from w ww . j a v a 2s. co m*/ return prefix + ':' + localName; }
From source file:org.jbpm.bpel.xml.util.XmlUtil.java
private static String formatQName(QName value, Element elem) { String namespace = value.getNamespaceURI(); String localName = value.getLocalPart(); // easy way out: no namespace if (namespace.length() == 0) return localName; String prefix = getPrefix(namespace, elem); if (prefix == null) { String givenPrefix = value.getPrefix(); prefix = generatePrefix(givenPrefix.length() > 0 ? givenPrefix : QUALIFIED_VALUE_PREFIX, elem); addNamespaceDeclaration(elem, namespace, prefix); }// w w w .j av a2s . c om return prefix + ':' + localName; }
From source file:org.jbpm.bpel.xml.util.XmlUtil.java
/** * Creates an element with the given qualified name. The returned element will be set as the * document element of its owner document. * @param name the qualified name of the element to create * @return a new element with the specified <code>name</code> *///w ww.j av a 2 s . co m public static Element createElement(QName name) { String namespace = name.getNamespaceURI(); String localName = name.getLocalPart(); if (namespace.length() == 0) return createElement(localName); String prefix = name.getPrefix(); return createElement(namespace, prefix.length() > 0 ? prefix + ':' + localName : localName); }
From source file:org.kalypso.gml.GMLSAXFactory.java
private void addAttribute(final AttributesImpl a, final QName name, final String type, final String value) throws SAXException { final String namespaceURI = name.getNamespaceURI(); final String localName = name.getLocalPart(); m_reader.getContentHandler().startPrefixMapping(name.getPrefix(), namespaceURI); final String qName = formatPrefixedQName(name); a.addAttribute(namespaceURI, localName, qName, type, value); }
From source file:org.kalypso.gml.GMLSAXFactory.java
private static String formatPrefixedQName(final QName name) { final String prefix = name.getPrefix(); final String localName = name.getLocalPart(); if (StringUtils.isBlank(prefix)) return localName; return prefix + ":" + localName; //$NON-NLS-1$ }
From source file:org.kalypso.gml.GMLSAXFactory.java
private String elementQName(final QName prefixedQName) { final String prefix = prefixedQName.getPrefix(); if (prefix.isEmpty()) return prefixedQName.getLocalPart(); return prefix + ":" + prefixedQName.getLocalPart(); }
From source file:org.kalypsodeegree.xml.XMLTools.java
/** * @param name/*w ww . j av a2 s. c om*/ * @param namespace * @param node */ public static QName getQNameValue(final Element element) { if (element == null) return null; final String value = getValue(element); if (StringUtils.isBlank(value)) return null; // hack to build a qName from string presentation (QName.toString()) // this is needed as the XML-SchemaType is still xs:string and not xs:QName // according to Markus U. Mller (OGC SLD-Editor) this will change in the next version in SLD Standard final int pos = value.indexOf('}'); if (value.startsWith("{") && pos > 0) return QName.valueOf(value); QName prefixedName = parsePrefixedQName(value); String prefix = prefixedName.getPrefix(); final String namespaceURI = element.lookupNamespaceURI(prefix); return new QName(namespaceURI, prefixedName.getLocalPart(), prefix); }