use of javax.xml.stream.events.Namespace in project hibernate-orm by hibernate.
the class JpaNamespaceTransformingEventReader method transform.
private StartElement transform(StartElement startElement) {
String elementName = startElement.getName().getLocalPart();
// use the start element to determine whether we have a persistence.xml or orm.xml
if (START_ELEMENT_TO_NAMESPACE_URI.containsKey(elementName)) {
currentDocumentNamespaceUri = START_ELEMENT_TO_NAMESPACE_URI.get(elementName);
}
List<Attribute> newElementAttributeList = updateElementAttributes(startElement);
List<Namespace> newNamespaceList = updateElementNamespaces(startElement);
// create the new element
return xmlEventFactory.createStartElement(new QName(currentDocumentNamespaceUri, startElement.getName().getLocalPart()), newElementAttributeList.iterator(), newNamespaceList.iterator());
}
use of javax.xml.stream.events.Namespace in project hibernate-orm by hibernate.
the class JpaOrmXmlEventReader method mapNamespaces.
private List<Namespace> mapNamespaces(Iterator<Namespace> originalNamespaceIterator) {
final List<Namespace> mappedNamespaces = new ArrayList<Namespace>();
while (originalNamespaceIterator.hasNext()) {
final Namespace originalNamespace = originalNamespaceIterator.next();
final Namespace mappedNamespace = mapNamespace(originalNamespace);
mappedNamespaces.add(mappedNamespace);
}
if (mappedNamespaces.isEmpty()) {
mappedNamespaces.add(xmlEventFactory.createNamespace(LocalSchema.ORM.getNamespaceUri()));
}
return mappedNamespaces;
}
use of javax.xml.stream.events.Namespace in project hibernate-orm by hibernate.
the class JpaOrmXmlEventReader method wrap.
private XMLEvent wrap(EndElement endElement) {
final List<Namespace> targetNamespaces = mapNamespaces(existingXmlNamespacesIterator(endElement));
// Transfer the location info from the incoming event to the event factory
// so that the event we ask it to generate for us has the same location info
xmlEventFactory.setLocation(endElement.getLocation());
return xmlEventFactory.createEndElement(new QName(LocalSchema.ORM.getNamespaceUri(), endElement.getName().getLocalPart()), targetNamespaces.iterator());
}
use of javax.xml.stream.events.Namespace in project spring-framework by spring-projects.
the class StaxEventXMLReader method handleEndElement.
private void handleEndElement(EndElement endElement) throws SAXException {
if (getContentHandler() != null) {
QName qName = endElement.getName();
if (hasNamespacesFeature()) {
getContentHandler().endElement(qName.getNamespaceURI(), qName.getLocalPart(), toQualifiedName(qName));
for (Iterator i = endElement.getNamespaces(); i.hasNext(); ) {
Namespace namespace = (Namespace) i.next();
endPrefixMapping(namespace.getPrefix());
}
} else {
getContentHandler().endElement("", "", toQualifiedName(qName));
}
}
}
use of javax.xml.stream.events.Namespace in project uPortal by Jasig.
the class PortletWindowRegistryImpl method addPortletWindowId.
protected StartElement addPortletWindowId(StartElement element, IPortletWindowId portletWindowId) {
final Attribute windowIdAttribute = xmlEventFactory.createAttribute(PORTLET_WINDOW_ID_ATTR_NAME, portletWindowId.getStringId());
// Clone the start element to add the new attribute
final QName name = element.getName();
final String prefix = name.getPrefix();
final String namespaceURI = name.getNamespaceURI();
final String localPart = name.getLocalPart();
@SuppressWarnings("unchecked") final Iterator<Attribute> attributes = element.getAttributes();
@SuppressWarnings("unchecked") final Iterator<Namespace> namespaces = element.getNamespaces();
final NamespaceContext namespaceContext = element.getNamespaceContext();
// Create a new iterator of the existing attributes + the new window id attribute
final Iterator<Attribute> newAttributes = Iterators.concat(attributes, Iterators.forArray(windowIdAttribute));
return xmlEventFactory.createStartElement(prefix, namespaceURI, localPart, newAttributes, namespaces, namespaceContext);
}
Aggregations