Java Code Examples for com.sun.org.apache.xml.internal.serializer.utils.Utils

The following examples show how to use com.sun.org.apache.xml.internal.serializer.utils.Utils. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: jdk1.8-source-analysis   Source File: SerializerBase.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Returns the URI of an element or attribute. Note that default namespaces
 * do not apply directly to attributes.
 * @param qname a qualified name
 * @param isElement true if the qualified name is the name of
 * an element.
 * @return returns the namespace URI associated with the qualified name.
 */
public String getNamespaceURI(String qname, boolean isElement)
{
    String uri = EMPTYSTRING;
    int col = qname.lastIndexOf(':');
    final String prefix = (col > 0) ? qname.substring(0, col) : EMPTYSTRING;

    if (!EMPTYSTRING.equals(prefix) || isElement)
    {
        if (m_prefixMap != null)
        {
            uri = m_prefixMap.lookupNamespace(prefix);
            if (uri == null && !prefix.equals(XMLNS_PREFIX))
            {
                throw new RuntimeException(
                    Utils.messages.createMessage(
                        MsgKey.ER_NAMESPACE_PREFIX,
                        new Object[] { qname.substring(0, col) }  ));
            }
        }
    }
    return uri;
}
 
Example 2
Source Project: TencentKona-8   Source File: SerializerBase.java    License: GNU General Public License v2.0 6 votes vote down vote up
/**
 * Returns the URI of an element or attribute. Note that default namespaces
 * do not apply directly to attributes.
 * @param qname a qualified name
 * @param isElement true if the qualified name is the name of
 * an element.
 * @return returns the namespace URI associated with the qualified name.
 */
public String getNamespaceURI(String qname, boolean isElement)
{
    String uri = EMPTYSTRING;
    int col = qname.lastIndexOf(':');
    final String prefix = (col > 0) ? qname.substring(0, col) : EMPTYSTRING;

    if (!EMPTYSTRING.equals(prefix) || isElement)
    {
        if (m_prefixMap != null)
        {
            uri = m_prefixMap.lookupNamespace(prefix);
            if (uri == null && !prefix.equals(XMLNS_PREFIX))
            {
                throw new RuntimeException(
                    Utils.messages.createMessage(
                        MsgKey.ER_NAMESPACE_PREFIX,
                        new Object[] { qname.substring(0, col) }  ));
            }
        }
    }
    return uri;
}
 
Example 3
Source Project: jdk8u60   Source File: SerializerBase.java    License: GNU General Public License v2.0 6 votes vote down vote up
/**
 * Returns the URI of an element or attribute. Note that default namespaces
 * do not apply directly to attributes.
 * @param qname a qualified name
 * @param isElement true if the qualified name is the name of
 * an element.
 * @return returns the namespace URI associated with the qualified name.
 */
public String getNamespaceURI(String qname, boolean isElement)
{
    String uri = EMPTYSTRING;
    int col = qname.lastIndexOf(':');
    final String prefix = (col > 0) ? qname.substring(0, col) : EMPTYSTRING;

    if (!EMPTYSTRING.equals(prefix) || isElement)
    {
        if (m_prefixMap != null)
        {
            uri = m_prefixMap.lookupNamespace(prefix);
            if (uri == null && !prefix.equals(XMLNS_PREFIX))
            {
                throw new RuntimeException(
                    Utils.messages.createMessage(
                        MsgKey.ER_NAMESPACE_PREFIX,
                        new Object[] { qname.substring(0, col) }  ));
            }
        }
    }
    return uri;
}
 
Example 4
Source Project: JDKSourceCode1.8   Source File: SerializerBase.java    License: MIT License 6 votes vote down vote up
/**
 * Returns the URI of an element or attribute. Note that default namespaces
 * do not apply directly to attributes.
 * @param qname a qualified name
 * @param isElement true if the qualified name is the name of
 * an element.
 * @return returns the namespace URI associated with the qualified name.
 */
public String getNamespaceURI(String qname, boolean isElement)
{
    String uri = EMPTYSTRING;
    int col = qname.lastIndexOf(':');
    final String prefix = (col > 0) ? qname.substring(0, col) : EMPTYSTRING;

    if (!EMPTYSTRING.equals(prefix) || isElement)
    {
        if (m_prefixMap != null)
        {
            uri = m_prefixMap.lookupNamespace(prefix);
            if (uri == null && !prefix.equals(XMLNS_PREFIX))
            {
                throw new RuntimeException(
                    Utils.messages.createMessage(
                        MsgKey.ER_NAMESPACE_PREFIX,
                        new Object[] { qname.substring(0, col) }  ));
            }
        }
    }
    return uri;
}
 
Example 5
Source Project: openjdk-jdk8u   Source File: SerializerBase.java    License: GNU General Public License v2.0 6 votes vote down vote up
/**
 * Returns the URI of an element or attribute. Note that default namespaces
 * do not apply directly to attributes.
 * @param qname a qualified name
 * @param isElement true if the qualified name is the name of
 * an element.
 * @return returns the namespace URI associated with the qualified name.
 */
public String getNamespaceURI(String qname, boolean isElement)
{
    String uri = EMPTYSTRING;
    int col = qname.lastIndexOf(':');
    final String prefix = (col > 0) ? qname.substring(0, col) : EMPTYSTRING;

    if (!EMPTYSTRING.equals(prefix) || isElement)
    {
        if (m_prefixMap != null)
        {
            uri = m_prefixMap.lookupNamespace(prefix);
            if (uri == null && !prefix.equals(XMLNS_PREFIX))
            {
                throw new RuntimeException(
                    Utils.messages.createMessage(
                        MsgKey.ER_NAMESPACE_PREFIX,
                        new Object[] { qname.substring(0, col) }  ));
            }
        }
    }
    return uri;
}
 
Example 6
/**
 * Returns the URI of an element or attribute. Note that default namespaces
 * do not apply directly to attributes.
 * @param qname a qualified name
 * @param isElement true if the qualified name is the name of
 * an element.
 * @return returns the namespace URI associated with the qualified name.
 */
public String getNamespaceURI(String qname, boolean isElement)
{
    String uri = EMPTYSTRING;
    int col = qname.lastIndexOf(':');
    final String prefix = (col > 0) ? qname.substring(0, col) : EMPTYSTRING;

    if (!EMPTYSTRING.equals(prefix) || isElement)
    {
        if (m_prefixMap != null)
        {
            uri = m_prefixMap.lookupNamespace(prefix);
            if (uri == null && !prefix.equals(XMLNS_PREFIX))
            {
                throw new RuntimeException(
                    Utils.messages.createMessage(
                        MsgKey.ER_NAMESPACE_PREFIX,
                        new Object[] { qname.substring(0, col) }  ));
            }
        }
    }
    return uri;
}
 
Example 7
Source Project: Bytecoder   Source File: SerializerBase.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Returns the URI of an element or attribute. Note that default namespaces
 * do not apply directly to attributes.
 * @param qname a qualified name
 * @param isElement true if the qualified name is the name of
 * an element.
 * @return returns the namespace URI associated with the qualified name.
 */
public String getNamespaceURI(String qname, boolean isElement) {
    String uri = EMPTYSTRING;
    int col = qname.lastIndexOf(':');
    final String prefix = (col > 0) ? qname.substring(0, col) : EMPTYSTRING;

    if (!EMPTYSTRING.equals(prefix) || isElement) {
        if (m_prefixMap != null) {
            uri = m_prefixMap.lookupNamespace(prefix);
            if (uri == null && !prefix.equals(XMLNS_PREFIX)) {
                throw new RuntimeException(
                    Utils.messages.createMessage(
                        MsgKey.ER_NAMESPACE_PREFIX,
                        new Object[] { qname.substring(0, col) }  ));
            }
        }
    }
    return uri;
}
 
Example 8
Source Project: Bytecoder   Source File: DOM3TreeWalker.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Checks if an CDATASection node is well-formed, by checking it's data
 * for well-formedness.  Note that the presence of a CDATA termination mark
 * in the contents of a CDATASection is handled by the parameter
 * spli-cdata-sections
 *
 * @param data The contents of the comment node
 */
protected void isCDATASectionWellFormed(CDATASection node) {
    // Does the data valid XML character data
    Character invalidChar = isWFXMLChar(node.getData());
    //if (!isWFXMLChar(node.getData(), invalidChar)) {
    if (invalidChar != null) {
        String msg =
            Utils.messages.createMessage(
                MsgKey.ER_WF_INVALID_CHARACTER_IN_CDATA,
                new Object[] { Integer.toHexString(Character.getNumericValue(invalidChar.charValue())) });

        if (fErrorHandler != null) {
            fErrorHandler.handleError(
                new DOMErrorImpl(
                    DOMError.SEVERITY_FATAL_ERROR,
                    msg,
                    MsgKey.ER_WF_INVALID_CHARACTER,
                    null,
                    null,
                    null));
        }
    }
}
 
Example 9
Source Project: Bytecoder   Source File: DOM3TreeWalker.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Checks if an Text node is well-formed, by checking if it contains invalid
 * XML characters.
 *
 * @param data The contents of the comment node
 */
protected void isTextWellFormed(Text node) {
    // Does the data valid XML character data
    Character invalidChar = isWFXMLChar(node.getData());
    if (invalidChar != null) {
        String msg =
            Utils.messages.createMessage(
                MsgKey.ER_WF_INVALID_CHARACTER_IN_TEXT,
                new Object[] { Integer.toHexString(Character.getNumericValue(invalidChar.charValue())) });

        if (fErrorHandler != null) {
            fErrorHandler.handleError(
                new DOMErrorImpl(
                    DOMError.SEVERITY_FATAL_ERROR,
                    msg,
                    MsgKey.ER_WF_INVALID_CHARACTER,
                    null,
                    null,
                    null));
        }
    }
}
 
Example 10
Source Project: openjdk-jdk9   Source File: SerializerBase.java    License: GNU General Public License v2.0 6 votes vote down vote up
/**
 * Returns the URI of an element or attribute. Note that default namespaces
 * do not apply directly to attributes.
 * @param qname a qualified name
 * @param isElement true if the qualified name is the name of
 * an element.
 * @return returns the namespace URI associated with the qualified name.
 */
public String getNamespaceURI(String qname, boolean isElement) {
    String uri = EMPTYSTRING;
    int col = qname.lastIndexOf(':');
    final String prefix = (col > 0) ? qname.substring(0, col) : EMPTYSTRING;

    if (!EMPTYSTRING.equals(prefix) || isElement) {
        if (m_prefixMap != null) {
            uri = m_prefixMap.lookupNamespace(prefix);
            if (uri == null && !prefix.equals(XMLNS_PREFIX)) {
                throw new RuntimeException(
                    Utils.messages.createMessage(
                        MsgKey.ER_NAMESPACE_PREFIX,
                        new Object[] { qname.substring(0, col) }  ));
            }
        }
    }
    return uri;
}
 
Example 11
Source Project: openjdk-jdk9   Source File: DOM3TreeWalker.java    License: GNU General Public License v2.0 6 votes vote down vote up
/**
 * Checks if an CDATASection node is well-formed, by checking it's data
 * for well-formedness.  Note that the presence of a CDATA termination mark
 * in the contents of a CDATASection is handled by the parameter
 * spli-cdata-sections
 *
 * @param data The contents of the comment node
 */
protected void isCDATASectionWellFormed(CDATASection node) {
    // Does the data valid XML character data
    Character invalidChar = isWFXMLChar(node.getData());
    //if (!isWFXMLChar(node.getData(), invalidChar)) {
    if (invalidChar != null) {
        String msg =
            Utils.messages.createMessage(
                MsgKey.ER_WF_INVALID_CHARACTER_IN_CDATA,
                new Object[] { Integer.toHexString(Character.getNumericValue(invalidChar.charValue())) });

        if (fErrorHandler != null) {
            fErrorHandler.handleError(
                new DOMErrorImpl(
                    DOMError.SEVERITY_FATAL_ERROR,
                    msg,
                    MsgKey.ER_WF_INVALID_CHARACTER,
                    null,
                    null,
                    null));
        }
    }
}
 
Example 12
Source Project: openjdk-jdk9   Source File: DOM3TreeWalker.java    License: GNU General Public License v2.0 6 votes vote down vote up
/**
 * Checks if an Text node is well-formed, by checking if it contains invalid
 * XML characters.
 *
 * @param data The contents of the comment node
 */
protected void isTextWellFormed(Text node) {
    // Does the data valid XML character data
    Character invalidChar = isWFXMLChar(node.getData());
    if (invalidChar != null) {
        String msg =
            Utils.messages.createMessage(
                MsgKey.ER_WF_INVALID_CHARACTER_IN_TEXT,
                new Object[] { Integer.toHexString(Character.getNumericValue(invalidChar.charValue())) });

        if (fErrorHandler != null) {
            fErrorHandler.handleError(
                new DOMErrorImpl(
                    DOMError.SEVERITY_FATAL_ERROR,
                    msg,
                    MsgKey.ER_WF_INVALID_CHARACTER,
                    null,
                    null,
                    null));
        }
    }
}
 
Example 13
Source Project: jdk1.8-source-analysis   Source File: ToStream.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Sets the character encoding coming from the xsl:output encoding stylesheet attribute.
 * @param encoding the character encoding
 */
public void setEncoding(String encoding)
{
    String old = getEncoding();
    super.setEncoding(encoding);
    if (old == null || !old.equals(encoding)) {
       // If we have changed the setting of the
       m_encodingInfo = Encodings.getEncodingInfo(encoding);

       if (encoding != null && m_encodingInfo.name == null) {
           // We tried to get an EncodingInfo for Object for the given
           // encoding, but it came back with an internall null name
           // so the encoding is not supported by the JDK, issue a message.
           String msg = Utils.messages.createMessage(
                           MsgKey.ER_ENCODING_NOT_SUPPORTED,new Object[]{ encoding });
           try
           {
                   // Prepare to issue the warning message
                   Transformer tran = super.getTransformer();
                   if (tran != null) {
                           ErrorListener errHandler = tran.getErrorListener();
                           // Issue the warning message
                           if (null != errHandler && m_sourceLocator != null)
                                   errHandler.warning(new TransformerException(msg, m_sourceLocator));
                           else
                                   System.out.println(msg);
               }
                   else
                           System.out.println(msg);
           }
           catch (Exception e){}
       }
    }
    return;
}
 
Example 14
Source Project: jdk1.8-source-analysis   Source File: ToXMLStream.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * This method checks for the XML version of output document.
 * If XML version of output document is not specified, then output
 * document is of version XML 1.0.
 * If XML version of output doucment is specified, but it is not either
 * XML 1.0 or XML 1.1, a warning message is generated, the XML Version of
 * output document is set to XML 1.0 and processing continues.
 * @return string (XML version)
 */
private String getXMLVersion()
{
    String xmlVersion = getVersion();
    if(xmlVersion == null || xmlVersion.equals(XMLVERSION10))
    {
        xmlVersion = XMLVERSION10;
    }
    else if(xmlVersion.equals(XMLVERSION11))
    {
        xmlVersion = XMLVERSION11;
    }
    else
    {
        String msg = Utils.messages.createMessage(
                           MsgKey.ER_XML_VERSION_NOT_SUPPORTED,new Object[]{ xmlVersion });
        try
        {
            // Prepare to issue the warning message
            Transformer tran = super.getTransformer();
            ErrorListener errHandler = tran.getErrorListener();
            // Issue the warning message
            if (null != errHandler && m_sourceLocator != null)
                errHandler.warning(new TransformerException(msg, m_sourceLocator));
            else
                System.out.println(msg);
        }
        catch (Exception e){}
        xmlVersion = XMLVERSION10;
    }
    return xmlVersion;
}
 
Example 15
Source Project: jdk1.8-source-analysis   Source File: ToHTMLStream.java    License: Apache License 2.0 5 votes vote down vote up
/**
 *  Receive notification of cdata.
 *
 *  <p>The Parser will call this method to report each chunk of
 *  character data.  SAX parsers may return all contiguous character
 *  data in a single chunk, or they may split it into several
 *  chunks; however, all of the characters in any single event
 *  must come from the same external entity, so that the Locator
 *  provides useful information.</p>
 *
 *  <p>The application must not attempt to read from the array
 *  outside of the specified range.</p>
 *
 *  <p>Note that some parsers will report whitespace using the
 *  ignorableWhitespace() method rather than this one (validating
 *  parsers must do so).</p>
 *
 *  @param ch The characters from the XML document.
 *  @param start The start position in the array.
 *  @param length The number of characters to read from the array.
 *  @throws org.xml.sax.SAXException Any SAX exception, possibly
 *             wrapping another exception.
 *  @see #ignorableWhitespace
 *  @see org.xml.sax.Locator
 *
 * @throws org.xml.sax.SAXException
 */
public final void cdata(char ch[], int start, int length)
    throws org.xml.sax.SAXException
{

    if ((null != m_elemContext.m_elementName)
        && (m_elemContext.m_elementName.equalsIgnoreCase("SCRIPT")
            || m_elemContext.m_elementName.equalsIgnoreCase("STYLE")))
    {
        try
        {
            if (m_elemContext.m_startTagOpen)
            {
                closeStartTag();
                m_elemContext.m_startTagOpen = false;
            }

            m_ispreserve = true;

            if (shouldIndent())
                indent();

            // writer.write(ch, start, length);
            writeNormalizedChars(ch, start, length, true, m_lineSepUse);
        }
        catch (IOException ioe)
        {
            throw new org.xml.sax.SAXException(
                Utils.messages.createMessage(
                    MsgKey.ER_OIERROR,
                    null),
                ioe);
            //"IO error", ioe);
        }
    }
    else
    {
        super.cdata(ch, start, length);
    }
}
 
Example 16
Source Project: TencentKona-8   Source File: ToStream.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Sets the character encoding coming from the xsl:output encoding stylesheet attribute.
 * @param encoding the character encoding
 */
public void setEncoding(String encoding)
{
    String old = getEncoding();
    super.setEncoding(encoding);
    if (old == null || !old.equals(encoding)) {
       // If we have changed the setting of the
       m_encodingInfo = Encodings.getEncodingInfo(encoding);

       if (encoding != null && m_encodingInfo.name == null) {
           // We tried to get an EncodingInfo for Object for the given
           // encoding, but it came back with an internall null name
           // so the encoding is not supported by the JDK, issue a message.
           String msg = Utils.messages.createMessage(
                           MsgKey.ER_ENCODING_NOT_SUPPORTED,new Object[]{ encoding });
           try
           {
                   // Prepare to issue the warning message
                   Transformer tran = super.getTransformer();
                   if (tran != null) {
                           ErrorListener errHandler = tran.getErrorListener();
                           // Issue the warning message
                           if (null != errHandler && m_sourceLocator != null)
                                   errHandler.warning(new TransformerException(msg, m_sourceLocator));
                           else
                                   System.out.println(msg);
               }
                   else
                           System.out.println(msg);
           }
           catch (Exception e){}
       }
    }
    return;
}
 
Example 17
Source Project: TencentKona-8   Source File: ToXMLStream.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * This method checks for the XML version of output document.
 * If XML version of output document is not specified, then output
 * document is of version XML 1.0.
 * If XML version of output doucment is specified, but it is not either
 * XML 1.0 or XML 1.1, a warning message is generated, the XML Version of
 * output document is set to XML 1.0 and processing continues.
 * @return string (XML version)
 */
private String getXMLVersion()
{
    String xmlVersion = getVersion();
    if(xmlVersion == null || xmlVersion.equals(XMLVERSION10))
    {
        xmlVersion = XMLVERSION10;
    }
    else if(xmlVersion.equals(XMLVERSION11))
    {
        xmlVersion = XMLVERSION11;
    }
    else
    {
        String msg = Utils.messages.createMessage(
                           MsgKey.ER_XML_VERSION_NOT_SUPPORTED,new Object[]{ xmlVersion });
        try
        {
            // Prepare to issue the warning message
            Transformer tran = super.getTransformer();
            ErrorListener errHandler = tran.getErrorListener();
            // Issue the warning message
            if (null != errHandler && m_sourceLocator != null)
                errHandler.warning(new TransformerException(msg, m_sourceLocator));
            else
                System.out.println(msg);
        }
        catch (Exception e){}
        xmlVersion = XMLVERSION10;
    }
    return xmlVersion;
}
 
Example 18
Source Project: TencentKona-8   Source File: ToHTMLStream.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 *  Receive notification of cdata.
 *
 *  <p>The Parser will call this method to report each chunk of
 *  character data.  SAX parsers may return all contiguous character
 *  data in a single chunk, or they may split it into several
 *  chunks; however, all of the characters in any single event
 *  must come from the same external entity, so that the Locator
 *  provides useful information.</p>
 *
 *  <p>The application must not attempt to read from the array
 *  outside of the specified range.</p>
 *
 *  <p>Note that some parsers will report whitespace using the
 *  ignorableWhitespace() method rather than this one (validating
 *  parsers must do so).</p>
 *
 *  @param ch The characters from the XML document.
 *  @param start The start position in the array.
 *  @param length The number of characters to read from the array.
 *  @throws org.xml.sax.SAXException Any SAX exception, possibly
 *             wrapping another exception.
 *  @see #ignorableWhitespace
 *  @see org.xml.sax.Locator
 *
 * @throws org.xml.sax.SAXException
 */
public final void cdata(char ch[], int start, int length)
    throws org.xml.sax.SAXException
{

    if ((null != m_elemContext.m_elementName)
        && (m_elemContext.m_elementName.equalsIgnoreCase("SCRIPT")
            || m_elemContext.m_elementName.equalsIgnoreCase("STYLE")))
    {
        try
        {
            if (m_elemContext.m_startTagOpen)
            {
                closeStartTag();
                m_elemContext.m_startTagOpen = false;
            }

            m_ispreserve = true;

            if (shouldIndent())
                indent();

            // writer.write(ch, start, length);
            writeNormalizedChars(ch, start, length, true, m_lineSepUse);
        }
        catch (IOException ioe)
        {
            throw new org.xml.sax.SAXException(
                Utils.messages.createMessage(
                    MsgKey.ER_OIERROR,
                    null),
                ioe);
            //"IO error", ioe);
        }
    }
    else
    {
        super.cdata(ch, start, length);
    }
}
 
Example 19
Source Project: jdk8u60   Source File: ToStream.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Sets the character encoding coming from the xsl:output encoding stylesheet attribute.
 * @param encoding the character encoding
 */
public void setEncoding(String encoding)
{
    String old = getEncoding();
    super.setEncoding(encoding);
    if (old == null || !old.equals(encoding)) {
       // If we have changed the setting of the
       m_encodingInfo = Encodings.getEncodingInfo(encoding);

       if (encoding != null && m_encodingInfo.name == null) {
           // We tried to get an EncodingInfo for Object for the given
           // encoding, but it came back with an internall null name
           // so the encoding is not supported by the JDK, issue a message.
           String msg = Utils.messages.createMessage(
                           MsgKey.ER_ENCODING_NOT_SUPPORTED,new Object[]{ encoding });
           try
           {
                   // Prepare to issue the warning message
                   Transformer tran = super.getTransformer();
                   if (tran != null) {
                           ErrorListener errHandler = tran.getErrorListener();
                           // Issue the warning message
                           if (null != errHandler && m_sourceLocator != null)
                                   errHandler.warning(new TransformerException(msg, m_sourceLocator));
                           else
                                   System.out.println(msg);
               }
                   else
                           System.out.println(msg);
           }
           catch (Exception e){}
       }
    }
    return;
}
 
Example 20
Source Project: jdk8u60   Source File: ToXMLStream.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * This method checks for the XML version of output document.
 * If XML version of output document is not specified, then output
 * document is of version XML 1.0.
 * If XML version of output doucment is specified, but it is not either
 * XML 1.0 or XML 1.1, a warning message is generated, the XML Version of
 * output document is set to XML 1.0 and processing continues.
 * @return string (XML version)
 */
private String getXMLVersion()
{
    String xmlVersion = getVersion();
    if(xmlVersion == null || xmlVersion.equals(XMLVERSION10))
    {
        xmlVersion = XMLVERSION10;
    }
    else if(xmlVersion.equals(XMLVERSION11))
    {
        xmlVersion = XMLVERSION11;
    }
    else
    {
        String msg = Utils.messages.createMessage(
                           MsgKey.ER_XML_VERSION_NOT_SUPPORTED,new Object[]{ xmlVersion });
        try
        {
            // Prepare to issue the warning message
            Transformer tran = super.getTransformer();
            ErrorListener errHandler = tran.getErrorListener();
            // Issue the warning message
            if (null != errHandler && m_sourceLocator != null)
                errHandler.warning(new TransformerException(msg, m_sourceLocator));
            else
                System.out.println(msg);
        }
        catch (Exception e){}
        xmlVersion = XMLVERSION10;
    }
    return xmlVersion;
}
 
Example 21
Source Project: jdk8u60   Source File: ToHTMLStream.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 *  Receive notification of cdata.
 *
 *  <p>The Parser will call this method to report each chunk of
 *  character data.  SAX parsers may return all contiguous character
 *  data in a single chunk, or they may split it into several
 *  chunks; however, all of the characters in any single event
 *  must come from the same external entity, so that the Locator
 *  provides useful information.</p>
 *
 *  <p>The application must not attempt to read from the array
 *  outside of the specified range.</p>
 *
 *  <p>Note that some parsers will report whitespace using the
 *  ignorableWhitespace() method rather than this one (validating
 *  parsers must do so).</p>
 *
 *  @param ch The characters from the XML document.
 *  @param start The start position in the array.
 *  @param length The number of characters to read from the array.
 *  @throws org.xml.sax.SAXException Any SAX exception, possibly
 *             wrapping another exception.
 *  @see #ignorableWhitespace
 *  @see org.xml.sax.Locator
 *
 * @throws org.xml.sax.SAXException
 */
public final void cdata(char ch[], int start, int length)
    throws org.xml.sax.SAXException
{

    if ((null != m_elemContext.m_elementName)
        && (m_elemContext.m_elementName.equalsIgnoreCase("SCRIPT")
            || m_elemContext.m_elementName.equalsIgnoreCase("STYLE")))
    {
        try
        {
            if (m_elemContext.m_startTagOpen)
            {
                closeStartTag();
                m_elemContext.m_startTagOpen = false;
            }

            m_ispreserve = true;

            if (shouldIndent())
                indent();

            // writer.write(ch, start, length);
            writeNormalizedChars(ch, start, length, true, m_lineSepUse);
        }
        catch (IOException ioe)
        {
            throw new org.xml.sax.SAXException(
                Utils.messages.createMessage(
                    MsgKey.ER_OIERROR,
                    null),
                ioe);
            //"IO error", ioe);
        }
    }
    else
    {
        super.cdata(ch, start, length);
    }
}
 
Example 22
Source Project: JDKSourceCode1.8   Source File: ToStream.java    License: MIT License 5 votes vote down vote up
/**
 * Sets the character encoding coming from the xsl:output encoding stylesheet attribute.
 * @param encoding the character encoding
 */
public void setEncoding(String encoding)
{
    String old = getEncoding();
    super.setEncoding(encoding);
    if (old == null || !old.equals(encoding)) {
       // If we have changed the setting of the
       m_encodingInfo = Encodings.getEncodingInfo(encoding);

       if (encoding != null && m_encodingInfo.name == null) {
           // We tried to get an EncodingInfo for Object for the given
           // encoding, but it came back with an internall null name
           // so the encoding is not supported by the JDK, issue a message.
           String msg = Utils.messages.createMessage(
                           MsgKey.ER_ENCODING_NOT_SUPPORTED,new Object[]{ encoding });
           try
           {
                   // Prepare to issue the warning message
                   Transformer tran = super.getTransformer();
                   if (tran != null) {
                           ErrorListener errHandler = tran.getErrorListener();
                           // Issue the warning message
                           if (null != errHandler && m_sourceLocator != null)
                                   errHandler.warning(new TransformerException(msg, m_sourceLocator));
                           else
                                   System.out.println(msg);
               }
                   else
                           System.out.println(msg);
           }
           catch (Exception e){}
       }
    }
    return;
}
 
Example 23
Source Project: JDKSourceCode1.8   Source File: ToXMLStream.java    License: MIT License 5 votes vote down vote up
/**
 * This method checks for the XML version of output document.
 * If XML version of output document is not specified, then output
 * document is of version XML 1.0.
 * If XML version of output doucment is specified, but it is not either
 * XML 1.0 or XML 1.1, a warning message is generated, the XML Version of
 * output document is set to XML 1.0 and processing continues.
 * @return string (XML version)
 */
private String getXMLVersion()
{
    String xmlVersion = getVersion();
    if(xmlVersion == null || xmlVersion.equals(XMLVERSION10))
    {
        xmlVersion = XMLVERSION10;
    }
    else if(xmlVersion.equals(XMLVERSION11))
    {
        xmlVersion = XMLVERSION11;
    }
    else
    {
        String msg = Utils.messages.createMessage(
                           MsgKey.ER_XML_VERSION_NOT_SUPPORTED,new Object[]{ xmlVersion });
        try
        {
            // Prepare to issue the warning message
            Transformer tran = super.getTransformer();
            ErrorListener errHandler = tran.getErrorListener();
            // Issue the warning message
            if (null != errHandler && m_sourceLocator != null)
                errHandler.warning(new TransformerException(msg, m_sourceLocator));
            else
                System.out.println(msg);
        }
        catch (Exception e){}
        xmlVersion = XMLVERSION10;
    }
    return xmlVersion;
}
 
Example 24
Source Project: JDKSourceCode1.8   Source File: ToHTMLStream.java    License: MIT License 5 votes vote down vote up
/**
 *  Receive notification of cdata.
 *
 *  <p>The Parser will call this method to report each chunk of
 *  character data.  SAX parsers may return all contiguous character
 *  data in a single chunk, or they may split it into several
 *  chunks; however, all of the characters in any single event
 *  must come from the same external entity, so that the Locator
 *  provides useful information.</p>
 *
 *  <p>The application must not attempt to read from the array
 *  outside of the specified range.</p>
 *
 *  <p>Note that some parsers will report whitespace using the
 *  ignorableWhitespace() method rather than this one (validating
 *  parsers must do so).</p>
 *
 *  @param ch The characters from the XML document.
 *  @param start The start position in the array.
 *  @param length The number of characters to read from the array.
 *  @throws org.xml.sax.SAXException Any SAX exception, possibly
 *             wrapping another exception.
 *  @see #ignorableWhitespace
 *  @see org.xml.sax.Locator
 *
 * @throws org.xml.sax.SAXException
 */
public final void cdata(char ch[], int start, int length)
    throws org.xml.sax.SAXException
{

    if ((null != m_elemContext.m_elementName)
        && (m_elemContext.m_elementName.equalsIgnoreCase("SCRIPT")
            || m_elemContext.m_elementName.equalsIgnoreCase("STYLE")))
    {
        try
        {
            if (m_elemContext.m_startTagOpen)
            {
                closeStartTag();
                m_elemContext.m_startTagOpen = false;
            }

            m_ispreserve = true;

            if (shouldIndent())
                indent();

            // writer.write(ch, start, length);
            writeNormalizedChars(ch, start, length, true, m_lineSepUse);
        }
        catch (IOException ioe)
        {
            throw new org.xml.sax.SAXException(
                Utils.messages.createMessage(
                    MsgKey.ER_OIERROR,
                    null),
                ioe);
            //"IO error", ioe);
        }
    }
    else
    {
        super.cdata(ch, start, length);
    }
}
 
Example 25
Source Project: openjdk-jdk9   Source File: ToXMLStream.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * This method checks for the XML version of output document.
 * If XML version of output document is not specified, then output
 * document is of version XML 1.0.
 * If XML version of output doucment is specified, but it is not either
 * XML 1.0 or XML 1.1, a warning message is generated, the XML Version of
 * output document is set to XML 1.0 and processing continues.
 * @return string (XML version)
 */
private String getXMLVersion()
{
    String xmlVersion = getVersion();
    if(xmlVersion == null || xmlVersion.equals(XMLVERSION10))
    {
        xmlVersion = XMLVERSION10;
    }
    else if(xmlVersion.equals(XMLVERSION11))
    {
        xmlVersion = XMLVERSION11;
    }
    else
    {
        String msg = Utils.messages.createMessage(
                           MsgKey.ER_XML_VERSION_NOT_SUPPORTED,new Object[]{ xmlVersion });
        try
        {
            // Prepare to issue the warning message
            Transformer tran = super.getTransformer();
            ErrorListener errHandler = tran.getErrorListener();
            // Issue the warning message
            if (null != errHandler && m_sourceLocator != null)
                errHandler.warning(new TransformerException(msg, m_sourceLocator));
            else
                System.out.println(msg);
        }
        catch (Exception e){}
        xmlVersion = XMLVERSION10;
    }
    return xmlVersion;
}
 
Example 26
Source Project: openjdk-jdk8u   Source File: ToStream.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Sets the character encoding coming from the xsl:output encoding stylesheet attribute.
 * @param encoding the character encoding
 */
public void setEncoding(String encoding)
{
    String old = getEncoding();
    super.setEncoding(encoding);
    if (old == null || !old.equals(encoding)) {
       // If we have changed the setting of the
       m_encodingInfo = Encodings.getEncodingInfo(encoding);

       if (encoding != null && m_encodingInfo.name == null) {
           // We tried to get an EncodingInfo for Object for the given
           // encoding, but it came back with an internall null name
           // so the encoding is not supported by the JDK, issue a message.
           String msg = Utils.messages.createMessage(
                           MsgKey.ER_ENCODING_NOT_SUPPORTED,new Object[]{ encoding });
           try
           {
                   // Prepare to issue the warning message
                   Transformer tran = super.getTransformer();
                   if (tran != null) {
                           ErrorListener errHandler = tran.getErrorListener();
                           // Issue the warning message
                           if (null != errHandler && m_sourceLocator != null)
                                   errHandler.warning(new TransformerException(msg, m_sourceLocator));
                           else
                                   System.out.println(msg);
               }
                   else
                           System.out.println(msg);
           }
           catch (Exception e){}
       }
    }
    return;
}
 
Example 27
Source Project: openjdk-jdk8u   Source File: ToXMLStream.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * This method checks for the XML version of output document.
 * If XML version of output document is not specified, then output
 * document is of version XML 1.0.
 * If XML version of output doucment is specified, but it is not either
 * XML 1.0 or XML 1.1, a warning message is generated, the XML Version of
 * output document is set to XML 1.0 and processing continues.
 * @return string (XML version)
 */
private String getXMLVersion()
{
    String xmlVersion = getVersion();
    if(xmlVersion == null || xmlVersion.equals(XMLVERSION10))
    {
        xmlVersion = XMLVERSION10;
    }
    else if(xmlVersion.equals(XMLVERSION11))
    {
        xmlVersion = XMLVERSION11;
    }
    else
    {
        String msg = Utils.messages.createMessage(
                           MsgKey.ER_XML_VERSION_NOT_SUPPORTED,new Object[]{ xmlVersion });
        try
        {
            // Prepare to issue the warning message
            Transformer tran = super.getTransformer();
            ErrorListener errHandler = tran.getErrorListener();
            // Issue the warning message
            if (null != errHandler && m_sourceLocator != null)
                errHandler.warning(new TransformerException(msg, m_sourceLocator));
            else
                System.out.println(msg);
        }
        catch (Exception e){}
        xmlVersion = XMLVERSION10;
    }
    return xmlVersion;
}
 
Example 28
Source Project: openjdk-jdk8u   Source File: ToHTMLStream.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 *  Receive notification of cdata.
 *
 *  <p>The Parser will call this method to report each chunk of
 *  character data.  SAX parsers may return all contiguous character
 *  data in a single chunk, or they may split it into several
 *  chunks; however, all of the characters in any single event
 *  must come from the same external entity, so that the Locator
 *  provides useful information.</p>
 *
 *  <p>The application must not attempt to read from the array
 *  outside of the specified range.</p>
 *
 *  <p>Note that some parsers will report whitespace using the
 *  ignorableWhitespace() method rather than this one (validating
 *  parsers must do so).</p>
 *
 *  @param ch The characters from the XML document.
 *  @param start The start position in the array.
 *  @param length The number of characters to read from the array.
 *  @throws org.xml.sax.SAXException Any SAX exception, possibly
 *             wrapping another exception.
 *  @see #ignorableWhitespace
 *  @see org.xml.sax.Locator
 *
 * @throws org.xml.sax.SAXException
 */
public final void cdata(char ch[], int start, int length)
    throws org.xml.sax.SAXException
{

    if ((null != m_elemContext.m_elementName)
        && (m_elemContext.m_elementName.equalsIgnoreCase("SCRIPT")
            || m_elemContext.m_elementName.equalsIgnoreCase("STYLE")))
    {
        try
        {
            if (m_elemContext.m_startTagOpen)
            {
                closeStartTag();
                m_elemContext.m_startTagOpen = false;
            }

            m_ispreserve = true;

            if (shouldIndent())
                indent();

            // writer.write(ch, start, length);
            writeNormalizedChars(ch, start, length, true, m_lineSepUse);
        }
        catch (IOException ioe)
        {
            throw new org.xml.sax.SAXException(
                Utils.messages.createMessage(
                    MsgKey.ER_OIERROR,
                    null),
                ioe);
            //"IO error", ioe);
        }
    }
    else
    {
        super.cdata(ch, start, length);
    }
}
 
Example 29
/**
 * Sets the character encoding coming from the xsl:output encoding stylesheet attribute.
 * @param encoding the character encoding
 */
public void setEncoding(String encoding)
{
    String old = getEncoding();
    super.setEncoding(encoding);
    if (old == null || !old.equals(encoding)) {
       // If we have changed the setting of the
       m_encodingInfo = Encodings.getEncodingInfo(encoding);

       if (encoding != null && m_encodingInfo.name == null) {
           // We tried to get an EncodingInfo for Object for the given
           // encoding, but it came back with an internall null name
           // so the encoding is not supported by the JDK, issue a message.
           String msg = Utils.messages.createMessage(
                           MsgKey.ER_ENCODING_NOT_SUPPORTED,new Object[]{ encoding });
           try
           {
                   // Prepare to issue the warning message
                   Transformer tran = super.getTransformer();
                   if (tran != null) {
                           ErrorListener errHandler = tran.getErrorListener();
                           // Issue the warning message
                           if (null != errHandler && m_sourceLocator != null)
                                   errHandler.warning(new TransformerException(msg, m_sourceLocator));
                           else
                                   System.out.println(msg);
               }
                   else
                           System.out.println(msg);
           }
           catch (Exception e){}
       }
    }
    return;
}
 
Example 30
/**
 * This method checks for the XML version of output document.
 * If XML version of output document is not specified, then output
 * document is of version XML 1.0.
 * If XML version of output doucment is specified, but it is not either
 * XML 1.0 or XML 1.1, a warning message is generated, the XML Version of
 * output document is set to XML 1.0 and processing continues.
 * @return string (XML version)
 */
private String getXMLVersion()
{
    String xmlVersion = getVersion();
    if(xmlVersion == null || xmlVersion.equals(XMLVERSION10))
    {
        xmlVersion = XMLVERSION10;
    }
    else if(xmlVersion.equals(XMLVERSION11))
    {
        xmlVersion = XMLVERSION11;
    }
    else
    {
        String msg = Utils.messages.createMessage(
                           MsgKey.ER_XML_VERSION_NOT_SUPPORTED,new Object[]{ xmlVersion });
        try
        {
            // Prepare to issue the warning message
            Transformer tran = super.getTransformer();
            ErrorListener errHandler = tran.getErrorListener();
            // Issue the warning message
            if (null != errHandler && m_sourceLocator != null)
                errHandler.warning(new TransformerException(msg, m_sourceLocator));
            else
                System.out.println(msg);
        }
        catch (Exception e){}
        xmlVersion = XMLVERSION10;
    }
    return xmlVersion;
}