Class SimpleNsStreamWriter

  • All Implemented Interfaces:
    OutputConfigFlags, javax.xml.stream.XMLStreamConstants, javax.xml.stream.XMLStreamWriter, org.codehaus.stax2.typed.TypedXMLStreamWriter, org.codehaus.stax2.validation.Validatable, org.codehaus.stax2.validation.ValidationContext, org.codehaus.stax2.XMLStreamWriter2

    public class SimpleNsStreamWriter
    extends BaseNsStreamWriter
    Namespace-aware implementation of XMLStreamWriter, that does not do namespace repairing, ie doesn't try to resolve possible conflicts between prefixes and namespace URIs, or automatically create namespace bindings.
    • Constructor Detail

      • SimpleNsStreamWriter

        public SimpleNsStreamWriter​(XmlWriter xw,
                                    java.lang.String enc,
                                    WriterConfig cfg)
    • Method Detail

      • writeAttribute

        public void writeAttribute​(java.lang.String nsURI,
                                   java.lang.String localName,
                                   java.lang.String value)
                            throws javax.xml.stream.XMLStreamException
        Specified by:
        writeAttribute in interface javax.xml.stream.XMLStreamWriter
        Specified by:
        writeAttribute in class BaseNsStreamWriter
        Throws:
        javax.xml.stream.XMLStreamException
      • writeAttribute

        public void writeAttribute​(java.lang.String prefix,
                                   java.lang.String nsURI,
                                   java.lang.String localName,
                                   java.lang.String value)
                            throws javax.xml.stream.XMLStreamException
        Specified by:
        writeAttribute in interface javax.xml.stream.XMLStreamWriter
        Specified by:
        writeAttribute in class BaseNsStreamWriter
        Throws:
        javax.xml.stream.XMLStreamException
      • writeDefaultNamespace

        public void writeDefaultNamespace​(java.lang.String nsURI)
                                   throws javax.xml.stream.XMLStreamException
        Specified by:
        writeDefaultNamespace in interface javax.xml.stream.XMLStreamWriter
        Specified by:
        writeDefaultNamespace in class BaseNsStreamWriter
        Throws:
        javax.xml.stream.XMLStreamException
      • writeNamespace

        public void writeNamespace​(java.lang.String prefix,
                                   java.lang.String nsURI)
                            throws javax.xml.stream.XMLStreamException
        Specified by:
        writeNamespace in interface javax.xml.stream.XMLStreamWriter
        Specified by:
        writeNamespace in class BaseNsStreamWriter
        Throws:
        javax.xml.stream.XMLStreamException
      • setDefaultNamespace

        public void setDefaultNamespace​(java.lang.String uri)
                                 throws javax.xml.stream.XMLStreamException
        Specified by:
        setDefaultNamespace in interface javax.xml.stream.XMLStreamWriter
        Specified by:
        setDefaultNamespace in class BaseNsStreamWriter
        Throws:
        javax.xml.stream.XMLStreamException
      • doSetPrefix

        public void doSetPrefix​(java.lang.String prefix,
                                java.lang.String uri)
                         throws javax.xml.stream.XMLStreamException
        Specified by:
        doSetPrefix in class BaseNsStreamWriter
        Throws:
        javax.xml.stream.XMLStreamException
      • writeStartElement

        public void writeStartElement​(javax.xml.stream.events.StartElement elem)
                               throws javax.xml.stream.XMLStreamException
        Description copied from class: BaseStreamWriter
        Convenience method needed by XMLEventWriter implementation, to use when writing a start element, and possibly its attributes and namespace declarations.
        Specified by:
        writeStartElement in class BaseNsStreamWriter
        Throws:
        javax.xml.stream.XMLStreamException
      • writeStartOrEmpty

        protected void writeStartOrEmpty​(java.lang.String localName,
                                         java.lang.String nsURI)
                                  throws javax.xml.stream.XMLStreamException
        Specified by:
        writeStartOrEmpty in class BaseNsStreamWriter
        Throws:
        javax.xml.stream.XMLStreamException
      • writeStartOrEmpty

        protected void writeStartOrEmpty​(java.lang.String prefix,
                                         java.lang.String localName,
                                         java.lang.String nsURI)
                                  throws javax.xml.stream.XMLStreamException
        Specified by:
        writeStartOrEmpty in class BaseNsStreamWriter
        Throws:
        javax.xml.stream.XMLStreamException
      • copyStartElement

        public final void copyStartElement​(InputElementStack elemStack,
                                           AttributeCollector attrCollector)
                                    throws java.io.IOException,
                                           javax.xml.stream.XMLStreamException
        Element copier method implementation suitable to be used with namespace-aware writers in non-repairing (explicit namespaces) mode. The trickiest thing is having to properly order calls to setPrefix, writeNamespace and writeStartElement; the order writers expect is bit different from the order in which element information is passed in.
        Specified by:
        copyStartElement in class BaseStreamWriter
        Throws:
        java.io.IOException
        javax.xml.stream.XMLStreamException
      • validateQNamePrefix

        public java.lang.String validateQNamePrefix​(javax.xml.namespace.QName name)
        Description copied from class: BaseStreamWriter
        Method called before writing a QName via Typed Access API. In namespace-repairing mode it should take appropriate actions to ensure that the given namespace URI is bound to a namespace and return whatever it maps to. In non-repairing work no additional work is to be done and methods
        Specified by:
        validateQNamePrefix in class BaseStreamWriter
        Returns:
        Prefix to use when writing out given QName as an element or attribute value