當前位置: 首頁>>代碼示例>>Java>>正文


Java LSInput.getPublicId方法代碼示例

本文整理匯總了Java中org.w3c.dom.ls.LSInput.getPublicId方法的典型用法代碼示例。如果您正苦於以下問題:Java LSInput.getPublicId方法的具體用法?Java LSInput.getPublicId怎麽用?Java LSInput.getPublicId使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.w3c.dom.ls.LSInput的用法示例。


在下文中一共展示了LSInput.getPublicId方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: resolveEntity

import org.w3c.dom.ls.LSInput; //導入方法依賴的package包/類
/**
 * Resolves the given resource and adapts the <code>LSInput</code>
 * returned into an <code>InputSource</code>.
 */
public InputSource resolveEntity(String name, String publicId,
        String baseURI, String systemId) throws SAXException, IOException {
    if (fEntityResolver != null) {
        LSInput lsInput = fEntityResolver.resolveResource(XML_TYPE, null, publicId, systemId, baseURI);
        if (lsInput != null) {
            final String pubId = lsInput.getPublicId();
            final String sysId = lsInput.getSystemId();
            final String baseSystemId = lsInput.getBaseURI();
            final Reader charStream = lsInput.getCharacterStream();
            final InputStream byteStream = lsInput.getByteStream();
            final String data = lsInput.getStringData();
            final String encoding = lsInput.getEncoding();

            /**
             * An LSParser looks at inputs specified in LSInput in
             * the following order: characterStream, byteStream,
             * stringData, systemId, publicId. For consistency
             * with the DOM Level 3 Load and Save Recommendation
             * use the same lookup order here.
             */
            InputSource inputSource = new InputSource();
            inputSource.setPublicId(pubId);
            inputSource.setSystemId((baseSystemId != null) ? resolveSystemId(systemId, baseSystemId) : systemId);

            if (charStream != null) {
                inputSource.setCharacterStream(charStream);
            }
            else if (byteStream != null) {
                inputSource.setByteStream(byteStream);
            }
            else if (data != null && data.length() != 0) {
                inputSource.setCharacterStream(new StringReader(data));
            }
            inputSource.setEncoding(encoding);
            return inputSource;
        }
    }
    return null;
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:44,代碼來源:ValidatorHandlerImpl.java

示例2: resolveEntity

import org.w3c.dom.ls.LSInput; //導入方法依賴的package包/類
/**
 * Resolves the given resource and adapts the <code>LSInput</code>
 * returned into an <code>InputSource</code>.
 */
public InputSource resolveEntity(String name, String publicId,
        String baseURI, String systemId) throws SAXException, IOException {
    if (fEntityResolver != null) {
        LSInput lsInput = fEntityResolver.resolveResource(XML_TYPE, null, publicId, systemId, baseURI);
        if (lsInput != null) {
            final String pubId = lsInput.getPublicId();
            final String sysId = lsInput.getSystemId();
            final String baseSystemId = lsInput.getBaseURI();
            final Reader charStream = lsInput.getCharacterStream();
            final InputStream byteStream = lsInput.getByteStream();
            final String data = lsInput.getStringData();
            final String encoding = lsInput.getEncoding();

            /**
             * An LSParser looks at inputs specified in LSInput in
             * the following order: characterStream, byteStream,
             * stringData, systemId, publicId. For consistency
             * with the DOM Level 3 Load and Save Recommendation
             * use the same lookup order here.
             */
            InputSource inputSource = new InputSource();
            inputSource.setPublicId(pubId);
            inputSource.setSystemId((baseSystemId != null) ? resolveSystemId(sysId, baseSystemId) : sysId);

            if (charStream != null) {
                inputSource.setCharacterStream(charStream);
            }
            else if (byteStream != null) {
                inputSource.setByteStream(byteStream);
            }
            else if (data != null && data.length() != 0) {
                inputSource.setCharacterStream(new StringReader(data));
            }
            inputSource.setEncoding(encoding);
            return inputSource;
        }
    }
    return null;
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:44,代碼來源:ValidatorHandlerImpl.java

示例3: dom2xmlInputSource

import org.w3c.dom.ls.LSInput; //導入方法依賴的package包/類
XMLInputSource dom2xmlInputSource(LSInput is) {
    // need to wrap the LSInput with an XMLInputSource
    XMLInputSource xis = null;

    /**
     * An LSParser looks at inputs specified in LSInput in
     * the following order: characterStream, byteStream,
     * stringData, systemId, publicId. For consistency
     * have the same behaviour for XSLoader.
     */

    // check whether there is a Reader
    // according to DOM, we need to treat such reader as "UTF-16".
    if (is.getCharacterStream() != null) {
        xis = new XMLInputSource(is.getPublicId(), is.getSystemId(),
                is.getBaseURI(), is.getCharacterStream(),
        "UTF-16");
    }
    // check whether there is an InputStream
    else if (is.getByteStream() != null) {
        xis = new XMLInputSource(is.getPublicId(), is.getSystemId(),
                is.getBaseURI(), is.getByteStream(),
                is.getEncoding());
    }
    // if there is a string data, use a StringReader
    // according to DOM, we need to treat such data as "UTF-16".
    else if (is.getStringData() != null && is.getStringData().length() != 0) {
        xis = new XMLInputSource(is.getPublicId(), is.getSystemId(),
                is.getBaseURI(), new StringReader(is.getStringData()),
        "UTF-16");
    }
    // otherwise, just use the public/system/base Ids
    else {
        xis = new XMLInputSource(is.getPublicId(), is.getSystemId(),
                is.getBaseURI());
    }

    return xis;
}
 
開發者ID:campolake,項目名稱:openjdk9,代碼行數:40,代碼來源:XMLSchemaLoader.java

示例4: resolveEntity

import org.w3c.dom.ls.LSInput; //導入方法依賴的package包/類
/**
 * Resolves the given resource and adapts the <code>LSInput</code>
 * returned into an <code>InputSource</code>.
 */
public InputSource resolveEntity(String name, String publicId, 
        String baseURI, String systemId) throws SAXException, IOException {
    if (fEntityResolver != null) {
        LSInput lsInput = fEntityResolver.resolveResource(XML_TYPE, null, publicId, systemId, baseURI);
        if (lsInput != null) {
            final String pubId = lsInput.getPublicId();
            final String sysId = lsInput.getSystemId();
            final String baseSystemId = lsInput.getBaseURI();
            final Reader charStream = lsInput.getCharacterStream();
            final InputStream byteStream = lsInput.getByteStream();
            final String data = lsInput.getStringData();
            final String encoding = lsInput.getEncoding();

            /**
             * An LSParser looks at inputs specified in LSInput in
             * the following order: characterStream, byteStream,
             * stringData, systemId, publicId. For consistency
             * with the DOM Level 3 Load and Save Recommendation
             * use the same lookup order here.
             */
            InputSource inputSource = new InputSource();
            inputSource.setPublicId(pubId);
            inputSource.setSystemId((baseSystemId != null) ? resolveSystemId(sysId, baseSystemId) : sysId);
            
            if (charStream != null) {
                inputSource.setCharacterStream(charStream);
            }
            else if (byteStream != null) {
                inputSource.setByteStream(byteStream);
            }
            else if (data != null && data.length() != 0) {
                inputSource.setCharacterStream(new StringReader(data));
            }
            inputSource.setEncoding(encoding);
            return inputSource;
        }
    }
    return null;
}
 
開發者ID:AaronZhangL,項目名稱:SplitCharater,代碼行數:44,代碼來源:ValidatorHandlerImpl.java

示例5: resolveEntity

import org.w3c.dom.ls.LSInput; //導入方法依賴的package包/類
/**
 * Resolves an external parsed entity. If the entity cannot be
 * resolved, this method should return null.
 *
 * @param resourceIdentifier        description of the resource to be revsoved
 * @throws XNIException Thrown on general error.
 * @throws IOException  Thrown if resolved entity stream cannot be
 *                      opened or some other i/o error occurs.
 */
public XMLInputSource resolveEntity(XMLResourceIdentifier resourceIdentifier)
    throws XNIException, IOException {
    // resolve entity using DOM entity resolver
    if (fEntityResolver != null) {
        // For entity resolution the type of the resource would be  XML TYPE
        // DOM L3 LS spec mention only the XML 1.0 recommendation right now
        LSInput inputSource =
            resourceIdentifier == null
                ? fEntityResolver.resolveResource(
                    null,
                    null,
                    null,
                    null,
                    null)
                : fEntityResolver.resolveResource(
                    getType(resourceIdentifier),
                    resourceIdentifier.getNamespace(),
                    resourceIdentifier.getPublicId(),
                    resourceIdentifier.getLiteralSystemId(),
                    resourceIdentifier.getBaseSystemId());
        if (inputSource != null) {
            String publicId = inputSource.getPublicId();
            String systemId = inputSource.getSystemId();
            String baseSystemId = inputSource.getBaseURI();
            InputStream byteStream = inputSource.getByteStream();
            Reader charStream = inputSource.getCharacterStream();
            String encoding = inputSource.getEncoding();
            String data = inputSource.getStringData();

            /**
             * An LSParser looks at inputs specified in LSInput in
             * the following order: characterStream, byteStream,
             * stringData, systemId, publicId.
             */
            XMLInputSource xmlInputSource =
                new XMLInputSource(publicId, systemId, baseSystemId);

            if (charStream != null) {
                xmlInputSource.setCharacterStream(charStream);
            }
            else if (byteStream != null) {
                xmlInputSource.setByteStream((InputStream) byteStream);
            }
            else if (data != null && data.length() != 0) {
                xmlInputSource.setCharacterStream(new StringReader(data));
            }
            xmlInputSource.setEncoding(encoding);
            return xmlInputSource;
        }
    }

    // unable to resolve entity
    return null;

}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:65,代碼來源:DOMEntityResolverWrapper.java

示例6: resolveEntity

import org.w3c.dom.ls.LSInput; //導入方法依賴的package包/類
/**
 * Resolves an external parsed entity. If the entity cannot be
 * resolved, this method should return null.
 *
 * @param resourceIdentifier        description of the resource to be revsoved
 * @throws XNIException Thrown on general error.
 * @throws IOException  Thrown if resolved entity stream cannot be
 *                      opened or some other i/o error occurs.
 */
public XMLInputSource resolveEntity(XMLResourceIdentifier resourceIdentifier)
    throws XNIException, IOException {
    // resolve entity using DOM entity resolver
    if (fEntityResolver != null) {
        // For entity resolution the type of the resource would be  XML TYPE
        // DOM L3 LS spec mention only the XML 1.0 recommendation right now
        LSInput inputSource =
            resourceIdentifier == null
                ? fEntityResolver.resolveResource(
                    null,
                    null,
                    null,
                    null,
                    null)
                : fEntityResolver.resolveResource(
                    getType(resourceIdentifier),
                    resourceIdentifier.getNamespace(),
                    resourceIdentifier.getPublicId(),
                    resourceIdentifier.getLiteralSystemId(),
                    resourceIdentifier.getBaseSystemId());
        if (inputSource != null) {
            String publicId = inputSource.getPublicId();
            String systemId = inputSource.getSystemId();
            String baseSystemId = inputSource.getBaseURI();
            InputStream byteStream = inputSource.getByteStream();
            Reader charStream = inputSource.getCharacterStream();
            String encoding = inputSource.getEncoding();
            String data = inputSource.getStringData();

            /**
             * An LSParser looks at inputs specified in LSInput in
             * the following order: characterStream, byteStream,
             * stringData, systemId, publicId.
             */
            XMLInputSource xmlInputSource =
                new XMLInputSource(publicId, systemId, baseSystemId, true);

            if (charStream != null) {
                xmlInputSource.setCharacterStream(charStream);
            }
            else if (byteStream != null) {
                xmlInputSource.setByteStream((InputStream) byteStream);
            }
            else if (data != null && data.length() != 0) {
                xmlInputSource.setCharacterStream(new StringReader(data));
            }
            xmlInputSource.setEncoding(encoding);
            return xmlInputSource;
        }
    }

    // unable to resolve entity
    return null;

}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:65,代碼來源:DOMEntityResolverWrapper.java

示例7: dom2xmlInputSource

import org.w3c.dom.ls.LSInput; //導入方法依賴的package包/類
/**
 * NON-DOM: convert LSInput to XNIInputSource
 *
 * @param is
 * @return
 */
XMLInputSource dom2xmlInputSource (LSInput is) {
    // need to wrap the LSInput with an XMLInputSource
    XMLInputSource xis = null;
    // check whether there is a Reader
    // according to DOM, we need to treat such reader as "UTF-16".
    if (is.getCharacterStream () != null) {
        xis = new XMLInputSource (is.getPublicId (), is.getSystemId (),
        is.getBaseURI (), is.getCharacterStream (),
        "UTF-16");
    }
    // check whether there is an InputStream
    else if (is.getByteStream () != null) {
        xis = new XMLInputSource (is.getPublicId (), is.getSystemId (),
        is.getBaseURI (), is.getByteStream (),
        is.getEncoding ());
    }
    // if there is a string data, use a StringReader
    // according to DOM, we need to treat such data as "UTF-16".
    else if (is.getStringData () != null && is.getStringData().length() > 0) {
        xis = new XMLInputSource (is.getPublicId (), is.getSystemId (),
        is.getBaseURI (), new StringReader (is.getStringData ()),
        "UTF-16");
    }
    // otherwise, just use the public/system/base Ids
    else if ((is.getSystemId() != null && is.getSystemId().length() > 0) ||
        (is.getPublicId() != null && is.getPublicId().length() > 0)) {
        xis = new XMLInputSource (is.getPublicId (), is.getSystemId (),
        is.getBaseURI ());
    }
    else {
        // all inputs are null
        if (fErrorHandler != null) {
            DOMErrorImpl error = new DOMErrorImpl();
            error.fType = "no-input-specified";
            error.fMessage = "no-input-specified";
            error.fSeverity = DOMError.SEVERITY_FATAL_ERROR;
            fErrorHandler.getErrorHandler().handleError(error);
        }
        throw new LSException(LSException.PARSE_ERR, "no-input-specified");
    }
    return xis;
}
 
開發者ID:campolake,項目名稱:openjdk9,代碼行數:49,代碼來源:DOMParserImpl.java

示例8: resolveEntity

import org.w3c.dom.ls.LSInput; //導入方法依賴的package包/類
/**
 * Resolves an external parsed entity. If the entity cannot be
 * resolved, this method should return null.
 *
 * @param resourceIdentifier	description of the resource to be revsoved
 * @throws XNIException Thrown on general error.
 * @throws IOException  Thrown if resolved entity stream cannot be
 *                      opened or some other i/o error occurs.
 */
public XMLInputSource resolveEntity(XMLResourceIdentifier resourceIdentifier)
    throws XNIException, IOException {
    // resolve entity using DOM entity resolver
    if (fEntityResolver != null) {
        // For entity resolution the type of the resource would be  XML TYPE
        // DOM L3 LS spec mention only the XML 1.0 recommendation right now
        LSInput inputSource =
            resourceIdentifier == null
                ? fEntityResolver.resolveResource(
                    null,
                    null,
                    null,
                    null,
                    null)
                : fEntityResolver.resolveResource(
                    getType(resourceIdentifier),
                    resourceIdentifier.getNamespace(),
                    resourceIdentifier.getPublicId(),
                    resourceIdentifier.getLiteralSystemId(),
                    resourceIdentifier.getBaseSystemId());
        if (inputSource != null) {
            String publicId = inputSource.getPublicId();
            String systemId = inputSource.getSystemId();
            String baseSystemId = inputSource.getBaseURI();
            InputStream byteStream = inputSource.getByteStream();
            Reader charStream = inputSource.getCharacterStream();
            String encoding = inputSource.getEncoding();
            String data = inputSource.getStringData();

            /**
             * An LSParser looks at inputs specified in LSInput in
             * the following order: characterStream, byteStream,
             * stringData, systemId, publicId.
             */          
            XMLInputSource xmlInputSource =
                new XMLInputSource(publicId, systemId, baseSystemId);
            
            if (charStream != null) {
                xmlInputSource.setCharacterStream(charStream);
            }
            else if (byteStream != null) {
                xmlInputSource.setByteStream((InputStream) byteStream);
            }
            else if (data != null && data.length() != 0) {
                xmlInputSource.setCharacterStream(new StringReader(data));
            }
            xmlInputSource.setEncoding(encoding);
            return xmlInputSource;
        }
    }

    // unable to resolve entity
    return null;

}
 
開發者ID:AaronZhangL,項目名稱:SplitCharater,代碼行數:65,代碼來源:DOMEntityResolverWrapper.java


注:本文中的org.w3c.dom.ls.LSInput.getPublicId方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。