Refine search
private void doWriteStartElement(StartElement startElement) throws XMLStreamException { this.eventWriter.add(startElement); this.endElements.add(this.eventFactory.createEndElement(startElement.getName(), startElement.getNamespaces())); }
private StartElement transform(StartElement event) { QName name = event.getName(); if (name.getNamespaceURI().length() == 0) { event = factory.createStartElement(name.getPrefix(), targetNamespaceUri, name.getLocalPart(), event.getAttributes(), event.getNamespaces(), event.getNamespaceContext()); } return event; }
private StartElement withNamespace(StartElement startElement) { // otherwise, wrap the start element event to provide a default namespace mapping final List<Namespace> namespaces = new ArrayList<Namespace>(); namespaces.add( xmlEventFactory.createNamespace( "", namespaceUri ) ); Iterator<?> originalNamespaces = startElement.getNamespaces(); while ( originalNamespaces.hasNext() ) { namespaces.add( (Namespace) originalNamespaces.next() ); } return xmlEventFactory.createStartElement( new QName( namespaceUri, startElement.getName().getLocalPart() ), startElement.getAttributes(), namespaces.iterator() ); }
public StartElementEvent(StartElement that) { this(that.getName(), that.getAttributes(), that.getNamespaces(), that.getNamespaceContext(), that.getLocation(), that.getSchemaType()); }
private void doWriteStartElement(StartElement startElement) throws XMLStreamException { this.eventWriter.add(startElement); this.endElements.add(this.eventFactory.createEndElement(startElement.getName(), startElement.getNamespaces())); }
private void handleStartElement(StartElement startElement) throws SAXException { if (getContentHandler() != null) { QName qName = startElement.getName(); if (hasNamespacesFeature()) { for (Iterator i = startElement.getNamespaces(); i.hasNext();) { Namespace namespace = (Namespace) i.next(); startPrefixMapping(namespace.getPrefix(), namespace.getNamespaceURI()); } for (Iterator i = startElement.getAttributes(); i.hasNext();){ Attribute attribute = (Attribute) i.next(); QName attributeName = attribute.getName(); startPrefixMapping(attributeName.getPrefix(), attributeName.getNamespaceURI()); } getContentHandler().startElement(qName.getNamespaceURI(), qName.getLocalPart(), toQualifiedName(qName), getAttributes(startElement)); } else { getContentHandler().startElement("", "", toQualifiedName(qName), getAttributes(startElement)); } } }
private void handleStartElement(StartElement startElement) throws SAXException { if (getContentHandler() != null) { QName qName = startElement.getName(); if (hasNamespacesFeature()) { for (Iterator i = startElement.getNamespaces(); i.hasNext();) { Namespace namespace = (Namespace) i.next(); startPrefixMapping(namespace.getPrefix(), namespace.getNamespaceURI()); } for (Iterator i = startElement.getAttributes(); i.hasNext();){ Attribute attribute = (Attribute) i.next(); QName attributeName = attribute.getName(); startPrefixMapping(attributeName.getPrefix(), attributeName.getNamespaceURI()); } getContentHandler().startElement(qName.getNamespaceURI(), qName.getLocalPart(), toQualifiedName(qName), getAttributes(startElement)); } else { getContentHandler().startElement("", "", toQualifiedName(qName), getAttributes(startElement)); } } }
final List<Namespace> targetNamespaces = new ArrayList<Namespace>(); if ( "".equals( startElement.getName().getNamespaceURI() ) ) { final Iterator<Namespace> originalNamespaces = startElement.getNamespaces(); while ( originalNamespaces.hasNext() ) { Namespace namespace = originalNamespaces.next(); new QName( MappingXsdSupport.INSTANCE.hbmXsd().getNamespaceUri(), startElement.getName().getLocalPart() ), startElement.getAttributes(), targetNamespaces.iterator()
private void handleStartElement(StartElement event) throws SAXException { // start namespace bindings for (Iterator i = event.getNamespaces(); i.hasNext();) { Namespace ns = (Namespace)i.next(); visitor.startPrefixMapping( fixNull(ns.getPrefix()), fixNull(ns.getNamespaceURI())); } // fire startElement QName qName = event.getName(); tagName.uri = fixNull(qName.getNamespaceURI()); String localName = qName.getLocalPart(); tagName.uri = fixNull(qName.getNamespaceURI()); tagName.local = localName; tagName.atts = getAttributes(event); visitor.startElement(tagName); seenText = false; }
} else if (event.isStartElement()) { StartElement element = event.asStartElement(); QName elQName = element.getName(); if (elQName.getPrefix().length() > 0 && elQName.getNamespaceURI().length() > 0) Iterator namespaces = element.getNamespaces(); while (namespaces.hasNext()) { Namespace ns = (Namespace) namespaces.next();
public boolean equals(Object o) { if (o == this) return true; if (o == null) return false; if (!(o instanceof StartElement)) return false; StartElement other = (StartElement) o; // First things first: names must match if (mName.equals(other.getName())) { /* Rest is much trickier. I guess the easiest way is to * just blindly iterate through ns decls and attributes. * The main issue is whether ordering should matter; it will, * if just iterating. Would need to sort to get canonical * comparison. */ if (iteratedEquals(getNamespaces(), other.getNamespaces())) { return iteratedEquals(getAttributes(), other.getAttributes()); } } return false; }
element = document.createElementNS(ele.getName() .getNamespaceURI(), ele.getName().getLocalPart()); ite = ele.getNamespaces(); while (ite.hasNext()) { Namespace ns = (Namespace) ite.next();
private void handleStartElement(StartElement startElement) throws SAXException { if (getContentHandler() != null) { QName qName = startElement.getName(); if (hasNamespacesFeature()) { for (Iterator i = startElement.getNamespaces(); i.hasNext();) { Namespace namespace = (Namespace) i.next(); startPrefixMapping(namespace.getPrefix(), namespace.getNamespaceURI()); } for (Iterator i = startElement.getAttributes(); i.hasNext();){ Attribute attribute = (Attribute) i.next(); QName attributeName = attribute.getName(); startPrefixMapping(attributeName.getPrefix(), attributeName.getNamespaceURI()); } getContentHandler().startElement(qName.getNamespaceURI(), qName.getLocalPart(), toQualifiedName(qName), getAttributes(startElement)); } else { getContentHandler().startElement("", "", toQualifiedName(qName), getAttributes(startElement)); } } }
private static final Element processElement(final JDOMFactory factory, final StartElement event) { final QName qname = event.getName(); final Element element = factory.element(qname.getLocalPart(), Namespace.getNamespace(qname.getPrefix(), qname.getNamespaceURI())); // Handle attributes for (final Iterator<?> it = event.getAttributes(); it.hasNext(); ) { final javax.xml.stream.events.Attribute att = (javax.xml.stream.events.Attribute)it.next(); final QName aqname = att.getName(); final Namespace attNs = Namespace.getNamespace(aqname.getPrefix(), aqname.getNamespaceURI()); factory.setAttribute(element, factory.attribute( aqname.getLocalPart(), att.getValue(), AttributeType.getAttributeType(att.getDTDType()), attNs)); } for (final Iterator<?> it = event.getNamespaces(); it.hasNext();) { final javax.xml.stream.events.Namespace ns = (javax.xml.stream.events.Namespace)it.next(); element.addNamespaceDeclaration(Namespace.getNamespace( ns.getPrefix(), ns.getNamespaceURI())); } return element; }
/** * Constructs a new DOM4J Element from the provided StartElement event. All * attributes and namespaces will be added to the returned element. * * @param startEvent * The StartElement event from which to construct the new DOM4J * Element. * * @return The Element constructed from the provided StartElement event. */ public Element createElement(StartElement startEvent) { QName qname = startEvent.getName(); org.dom4j.QName elemName = createQName(qname); Element elem = factory.createElement(elemName); // create attributes for (Iterator<Attribute> i = startEvent.getAttributes(); i.hasNext();) { Attribute attr = i.next(); elem.addAttribute(createQName(attr.getName()), attr.getValue()); } // create namespaces for (Iterator<Namespace> i = startEvent.getNamespaces(); i.hasNext();) { Namespace ns = i.next(); elem.addNamespace(ns.getPrefix(), ns.getNamespaceURI()); } return elem; }
private void handleStartElement(StartElement event) throws SAXException { // start namespace bindings for (Iterator i = event.getNamespaces(); i.hasNext();) { Namespace ns = (Namespace)i.next(); visitor.startPrefixMapping( fixNull(ns.getPrefix()), fixNull(ns.getNamespaceURI())); } // fire startElement QName qName = event.getName(); tagName.uri = fixNull(qName.getNamespaceURI()); String localName = qName.getLocalPart(); tagName.uri = fixNull(qName.getNamespaceURI()); tagName.local = localName; tagName.atts = getAttributes(event); visitor.startElement(tagName); seenText = false; }
public void writeStartElement(StartElement elem) throws XMLStreamException QName name = elem.getName(); Iterator it = elem.getNamespaces(); it = elem.getNamespaces(); while (it.hasNext()) { Namespace ns = (Namespace) it.next();
/** Create a new start element based on the original but that does not include * any attributes. */ private StartElement getEmptyStartEvent(XMLEvent event) { StartElement oldStartEvent = event.asStartElement(); return xmlEventFactory.createStartElement(oldStartEvent.getName(), null, oldStartEvent.getNamespaces()); }
public static StartElementBuilder from(StartElement originalElt) { return new StartElementBuilder(originalElt.getName(), originalElt.getAttributes(), originalElt.getNamespaces()); }
/** * Writes a {@link StartElement} event to the provided stream. * * @param start The {@link StartElement} event to write. * @param writer The destination stream. * @throws IOException If an error occurs writing to the stream. * @throws XMLStreamException If an error occurs writing any namespaces or * attribute events. */ public static final void writeStartElement(StartElement start, Writer writer) throws IOException, XMLStreamException { writeStartElement(start.getName(), start.getAttributes(), start.getNamespaces(), false, writer); }