/** * Method for accessing namespace prefix of the START_ELEMENT this * cursor points to. * * @return Prefix of currently pointed-to START_ELEMENT, * if it has one; "" if none * * @throws XMLStreamException if cursor does not point to START_ELEMENT */ public String getPrefix() throws XMLStreamException { if (!readerAccessible()) { throw _notAccessible("getPrefix"); } String prefix = _streamReader.getPrefix(); // some impls may return null instead, let's convert return (prefix == null) ? "" : prefix; }
/** * Method for accessing namespace prefix of the START_ELEMENT this * cursor points to. * * @return Prefix of currently pointed-to START_ELEMENT, * if it has one; "" if none * * @throws XMLStreamException if cursor does not point to START_ELEMENT */ public String getPrefix() throws XMLStreamException { if (!readerAccessible()) { throw _notAccessible("getPrefix"); } String prefix = _streamReader.getPrefix(); // some impls may return null instead, let's convert return (prefix == null) ? "" : prefix; }
public void writeStartElement(XMLStreamReader2 reader, XMLStreamWriter2 writer) throws XMLStreamException { String uri = reader.getNamespaceURI(); String prefix = reader.getPrefix(); String local = reader.getLocalName(); writer.writeStartElement(prefix, local, uri); // Write out the namespaces for (int i = 0; i < reader.getNamespaceCount(); i++) { String nsURI = reader.getNamespaceURI(i); String nsPrefix = reader.getNamespacePrefix(i); writer.writeNamespace(nsPrefix, nsURI); } }
/** * Method cursor calls when it needs to track element state information; * if so, it calls this method to take a snapshot of the element. *<p> * Note caller already suppresses calls so that this method is only * called when information needs to be preserved. Further, previous * element is only passed if such linkage is to be preserved (reason * for not always doing it is the increased memory usage). *<p> * Finally, note that this method does NOT implement * {@link ElementInfoFactory}, as its signature does not include the * cursor argument, as that's passed as this pointer already. */ protected SMElementInfo constructElementInfo(SMElementInfo parent, SMElementInfo prevSibling) throws XMLStreamException { if (mElemInfoFactory != null) { return mElemInfoFactory.constructElementInfo(this, parent, prevSibling); } XMLStreamReader2 sr = _streamReader; return new DefaultElementInfo(parent, prevSibling, sr.getPrefix(), sr.getNamespaceURI(), sr.getLocalName(), _nodeCount-1, _elemCount-1, getParentCount()); }
/** * Method cursor calls when it needs to track element state information; * if so, it calls this method to take a snapshot of the element. *<p> * Note caller already suppresses calls so that this method is only * called when information needs to be preserved. Further, previous * element is only passed if such linkage is to be preserved (reason * for not always doing it is the increased memory usage). *<p> * Finally, note that this method does NOT implement * {@link ElementInfoFactory}, as its signature does not include the * cursor argument, as that's passed as this pointer already. */ protected SMElementInfo constructElementInfo(SMElementInfo parent, SMElementInfo prevSibling) throws XMLStreamException { if (mElemInfoFactory != null) { return mElemInfoFactory.constructElementInfo(this, parent, prevSibling); } XMLStreamReader2 sr = _streamReader; return new DefaultElementInfo(parent, prevSibling, sr.getPrefix(), sr.getNamespaceURI(), sr.getLocalName(), _nodeCount-1, _elemCount-1, getParentCount()); }