com.sun.org.apache.xerces.internal.parsers.DOMParser Java Examples

The following examples show how to use com.sun.org.apache.xerces.internal.parsers.DOMParser. 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 File: DocumentBuilderFactoryImpl.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
public boolean getFeature(String name)
    throws ParserConfigurationException {
    if (name.equals(XMLConstants.FEATURE_SECURE_PROCESSING)) {
        return fSecureProcess;
    }
    // See if it's in the features Hashtable
    if (features != null) {
        Object val = features.get(name);
        if (val != null) {
            return ((Boolean) val).booleanValue();
        }
    }
    try {
        DOMParser domParser = new DocumentBuilderImpl(this, attributes, features).getDOMParser();
        return domParser.getFeature(name);
    }
    catch (SAXException e) {
        throw new ParserConfigurationException(e.getMessage());
    }
}
 
Example #2
Source File: DocumentBuilderFactoryImpl.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
public boolean getFeature(String name)
    throws ParserConfigurationException {
    if (name.equals(XMLConstants.FEATURE_SECURE_PROCESSING)) {
        return fSecureProcess;
    }
    // See if it's in the features map
    if (features != null) {
        Boolean val = features.get(name);
        if (val != null) {
            return val;
        }
    }
    try {
        DOMParser domParser = new DocumentBuilderImpl(this, attributes, features).getDOMParser();
        return domParser.getFeature(name);
    }
    catch (SAXException e) {
        throw new ParserConfigurationException(e.getMessage());
    }
}
 
Example #3
Source File: DocumentBuilderFactoryImpl.java    From jdk1.8-source-analysis with Apache License 2.0 6 votes vote down vote up
public boolean getFeature(String name)
    throws ParserConfigurationException {
    if (name.equals(XMLConstants.FEATURE_SECURE_PROCESSING)) {
        return fSecureProcess;
    }
    // See if it's in the features map
    if (features != null) {
        Boolean val = features.get(name);
        if (val != null) {
            return val;
        }
    }
    try {
        DOMParser domParser = new DocumentBuilderImpl(this, attributes, features).getDOMParser();
        return domParser.getFeature(name);
    }
    catch (SAXException e) {
        throw new ParserConfigurationException(e.getMessage());
    }
}
 
Example #4
Source File: DocumentBuilderFactoryImpl.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
public boolean getFeature(String name)
    throws ParserConfigurationException {
    if (name.equals(XMLConstants.FEATURE_SECURE_PROCESSING)) {
        return fSecureProcess;
    }
    // See if it's in the features Hashtable
    if (features != null) {
        Object val = features.get(name);
        if (val != null) {
            return ((Boolean) val).booleanValue();
        }
    }
    try {
        DOMParser domParser = new DocumentBuilderImpl(this, attributes, features).getDOMParser();
        return domParser.getFeature(name);
    }
    catch (SAXException e) {
        throw new ParserConfigurationException(e.getMessage());
    }
}
 
Example #5
Source File: DocumentBuilderFactoryImpl.java    From JDKSourceCode1.8 with MIT License 6 votes vote down vote up
public boolean getFeature(String name)
    throws ParserConfigurationException {
    if (name.equals(XMLConstants.FEATURE_SECURE_PROCESSING)) {
        return fSecureProcess;
    }
    // See if it's in the features map
    if (features != null) {
        Boolean val = features.get(name);
        if (val != null) {
            return val;
        }
    }
    try {
        DOMParser domParser = new DocumentBuilderImpl(this, attributes, features).getDOMParser();
        return domParser.getFeature(name);
    }
    catch (SAXException e) {
        throw new ParserConfigurationException(e.getMessage());
    }
}
 
Example #6
Source File: DocumentBuilderFactoryImpl.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
public boolean getFeature(String name)
    throws ParserConfigurationException {
    if (name.equals(XMLConstants.FEATURE_SECURE_PROCESSING)) {
        return fSecureProcess;
    }
    // See if it's in the features map
    if (features != null) {
        Boolean val = features.get(name);
        if (val != null) {
            return val;
        }
    }
    try {
        DOMParser domParser = new DocumentBuilderImpl(this, attributes, features).getDOMParser();
        return domParser.getFeature(name);
    }
    catch (SAXException e) {
        throw new ParserConfigurationException(e.getMessage());
    }
}
 
Example #7
Source File: DocumentBuilderFactoryImpl.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
public boolean getFeature(String name)
    throws ParserConfigurationException {
    if (name.equals(XMLConstants.FEATURE_SECURE_PROCESSING)) {
        return fSecureProcess;
    }
    // See if it's in the features map
    if (features != null) {
        Boolean val = features.get(name);
        if (val != null) {
            return val;
        }
    }
    try {
        DOMParser domParser = new DocumentBuilderImpl(this, attributes, features).getDOMParser();
        return domParser.getFeature(name);
    }
    catch (SAXException e) {
        throw new ParserConfigurationException(e.getMessage());
    }
}
 
Example #8
Source File: DocumentBuilderFactoryImpl.java    From Bytecoder with Apache License 2.0 6 votes vote down vote up
public boolean getFeature(String name)
    throws ParserConfigurationException {
    if (name.equals(XMLConstants.FEATURE_SECURE_PROCESSING)) {
        return fSecureProcess;
    }
    // See if it's in the features map
    if (features != null) {
        Boolean val = features.get(name);
        if (val != null) {
            return val;
        }
    }
    try {
        DOMParser domParser = new DocumentBuilderImpl(this, attributes, features).getDOMParser();
        return domParser.getFeature(name);
    }
    catch (SAXException e) {
        throw new ParserConfigurationException(e.getMessage());
    }
}
 
Example #9
Source File: DocumentBuilderFactoryImpl.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
public boolean getFeature(String name)
    throws ParserConfigurationException {
    if (name.equals(XMLConstants.FEATURE_SECURE_PROCESSING)) {
        return fSecureProcess;
    }
    // See if it's in the features map
    if (features != null) {
        Boolean val = features.get(name);
        if (val != null) {
            return val;
        }
    }
    try {
        DOMParser domParser = new DocumentBuilderImpl(this, attributes, features).getDOMParser();
        return domParser.getFeature(name);
    }
    catch (SAXException e) {
        throw new ParserConfigurationException(e.getMessage());
    }
}
 
Example #10
Source File: DocumentBuilderFactoryImpl.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
public boolean getFeature(String name)
    throws ParserConfigurationException {
    if (name.equals(XMLConstants.FEATURE_SECURE_PROCESSING)) {
        return fSecureProcess;
    }
    // See if it's in the features map
    if (features != null) {
        Boolean val = features.get(name);
        if (val != null) {
            return val;
        }
    }
    try {
        DOMParser domParser = new DocumentBuilderImpl(this, attributes, features).getDOMParser();
        return domParser.getFeature(name);
    }
    catch (SAXException e) {
        throw new ParserConfigurationException(e.getMessage());
    }
}
 
Example #11
Source File: DocumentBuilderFactoryImpl.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
public boolean getFeature(String name)
    throws ParserConfigurationException {
    if (name.equals(XMLConstants.FEATURE_SECURE_PROCESSING)) {
        return fSecureProcess;
    }
    // See if it's in the features Hashtable
    if (features != null) {
        Object val = features.get(name);
        if (val != null) {
            return ((Boolean) val).booleanValue();
        }
    }
    try {
        DOMParser domParser = new DocumentBuilderImpl(this, attributes, features).getDOMParser();
        return domParser.getFeature(name);
    }
    catch (SAXException e) {
        throw new ParserConfigurationException(e.getMessage());
    }
}
 
Example #12
Source File: DocumentBuilderFactoryImpl.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Allows the user to retrieve specific attributes on the underlying
 * implementation.
 */
public Object getAttribute(String name)
    throws IllegalArgumentException
{
    // See if it's in the attributes Hashtable
    if (attributes != null) {
        Object val = attributes.get(name);
        if (val != null) {
            return val;
        }
    }

    DOMParser domParser = null;
    try {
        // We create a dummy DocumentBuilderImpl in case the attribute
        // name is not one that is in the attributes hashtable.
        domParser =
            new DocumentBuilderImpl(this, attributes, features).getDOMParser();
        return domParser.getProperty(name);
    } catch (SAXException se1) {
        // assert(name is not recognized or not supported), try feature
        try {
            boolean result = domParser.getFeature(name);
            // Must have been a feature
            return result ? Boolean.TRUE : Boolean.FALSE;
        } catch (SAXException se2) {
            // Not a property or a feature
            throw new IllegalArgumentException(se1.getMessage());
        }
    }
}
 
Example #13
Source File: XSAnnotationImpl.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
private synchronized void writeToDOM(Node target, short type) {
    Document futureOwner = (type == XSAnnotation.W3C_DOM_ELEMENT) ?
            target.getOwnerDocument() : (Document)target;
    DOMParser parser = fGrammar.getDOMParser();
    StringReader aReader = new StringReader(fData);
    InputSource aSource = new InputSource(aReader);
    try {
        parser.parse(aSource);
    }
    catch (SAXException e) {
        // this should never happen!
        // REVISIT:  what to do with this?; should really not
        // eat it...
    }
    catch (IOException i) {
        // ditto with above
    }
    Document aDocument = parser.getDocument();
    parser.dropDocumentReferences();
    Element annotation = aDocument.getDocumentElement();
    Node newElem = null;
    if (futureOwner instanceof CoreDocumentImpl) {
        newElem = futureOwner.adoptNode(annotation);
        // adoptNode will return null when the DOM implementations are not compatible.
        if (newElem == null) {
            newElem = futureOwner.importNode(annotation, true);
        }
    }
    else {
        newElem = futureOwner.importNode(annotation, true);
    }
    target.insertBefore(newElem, target.getFirstChild());
}
 
Example #14
Source File: FDom.java    From pra with MIT License 5 votes vote down vote up
public Element LoadHTML(String filename){
		
		FileInputStream inStream;
		String s = new String();
		String urlIS = new String(filename);
		
		try	{
			DOMParser parser = new DOMParser();
			parser.parse(new InputSource(new FileInputStream(urlIS)));
			Document doc= parser.getDocument();
			return doc.getDocumentElement();
			//HTMLInputElement hi = (HTMLInputElement)doc.getElementById("search");
		}
		catch (Exception e)	{
			return null;
		}

/*		StringWriter sw = new StringWriter();
		Transformer t = null;
		try
		{
			t = TransformerFactory.newInstance().newTransformer(); 
		}
		catch (Exception e)
		{
			return "";
		}
		t.setOutputProperty(OutputKeys.METHOD, "html");
		t.setOutputProperty(OutputKeys.OMIT_XML_DECLARATIO N, "yes");
		try
		{
			t.transform(new DOMSource(doc), new StreamResult(sw));
		}
		catch (Exception e)
		{
			return "";
		}
		s = sw.toString();
		return s;*/
	}
 
Example #15
Source File: DocumentBuilderFactoryImpl.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Allows the user to retrieve specific attributes on the underlying
 * implementation.
 */
public Object getAttribute(String name)
    throws IllegalArgumentException
{
    // See if it's in the attributes Map
    if (attributes != null) {
        Object val = attributes.get(name);
        if (val != null) {
            return val;
        }
    }

    DOMParser domParser = null;
    try {
        // We create a dummy DocumentBuilderImpl in case the attribute
        // name is not one that is in the attributes map.
        domParser =
            new DocumentBuilderImpl(this, attributes, features).getDOMParser();
        return domParser.getProperty(name);
    } catch (SAXException se1) {
        // assert(name is not recognized or not supported), try feature
        try {
            boolean result = domParser.getFeature(name);
            // Must have been a feature
            return result ? Boolean.TRUE : Boolean.FALSE;
        } catch (SAXException se2) {
            // Not a property or a feature
            throw new IllegalArgumentException(se1.getMessage());
        }
    }
}
 
Example #16
Source File: DocumentBuilderFactoryImpl.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Allows the user to retrieve specific attributes on the underlying
 * implementation.
 */
public Object getAttribute(String name)
    throws IllegalArgumentException
{
    // See if it's in the attributes Map
    if (attributes != null) {
        Object val = attributes.get(name);
        if (val != null) {
            return val;
        }
    }

    DOMParser domParser = null;
    try {
        // We create a dummy DocumentBuilderImpl in case the attribute
        // name is not one that is in the attributes map.
        domParser =
            new DocumentBuilderImpl(this, attributes, features).getDOMParser();
        return domParser.getProperty(name);
    } catch (SAXException se1) {
        // assert(name is not recognized or not supported), try feature
        try {
            boolean result = domParser.getFeature(name);
            // Must have been a feature
            return result ? Boolean.TRUE : Boolean.FALSE;
        } catch (SAXException se2) {
            // Not a property or a feature
            throw new IllegalArgumentException(se1.getMessage());
        }
    }
}
 
Example #17
Source File: XSAnnotationImpl.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
private synchronized void writeToDOM(Node target, short type) {
    Document futureOwner = (type == XSAnnotation.W3C_DOM_ELEMENT) ?
            target.getOwnerDocument() : (Document)target;
    DOMParser parser = fGrammar.getDOMParser();
    StringReader aReader = new StringReader(fData);
    InputSource aSource = new InputSource(aReader);
    try {
        parser.parse(aSource);
    }
    catch (SAXException e) {
        // this should never happen!
        // REVISIT:  what to do with this?; should really not
        // eat it...
    }
    catch (IOException i) {
        // ditto with above
    }
    Document aDocument = parser.getDocument();
    parser.dropDocumentReferences();
    Element annotation = aDocument.getDocumentElement();
    Node newElem = null;
    if (futureOwner instanceof CoreDocumentImpl) {
        newElem = futureOwner.adoptNode(annotation);
        // adoptNode will return null when the DOM implementations are not compatible.
        if (newElem == null) {
            newElem = futureOwner.importNode(annotation, true);
        }
    }
    else {
        newElem = futureOwner.importNode(annotation, true);
    }
    target.insertBefore(newElem, target.getFirstChild());
}
 
Example #18
Source File: XSAnnotationImpl.java    From jdk1.8-source-analysis with Apache License 2.0 5 votes vote down vote up
private synchronized void writeToDOM(Node target, short type) {
    Document futureOwner = (type == XSAnnotation.W3C_DOM_ELEMENT) ?
            target.getOwnerDocument() : (Document)target;
    DOMParser parser = fGrammar.getDOMParser();
    StringReader aReader = new StringReader(fData);
    InputSource aSource = new InputSource(aReader);
    try {
        parser.parse(aSource);
    }
    catch (SAXException e) {
        // this should never happen!
        // REVISIT:  what to do with this?; should really not
        // eat it...
    }
    catch (IOException i) {
        // ditto with above
    }
    Document aDocument = parser.getDocument();
    parser.dropDocumentReferences();
    Element annotation = aDocument.getDocumentElement();
    Node newElem = null;
    if (futureOwner instanceof CoreDocumentImpl) {
        newElem = futureOwner.adoptNode(annotation);
        // adoptNode will return null when the DOM implementations are not compatible.
        if (newElem == null) {
            newElem = futureOwner.importNode(annotation, true);
        }
    }
    else {
        newElem = futureOwner.importNode(annotation, true);
    }
    target.insertBefore(newElem, target.getFirstChild());
}
 
Example #19
Source File: XSAnnotationImpl.java    From Bytecoder with Apache License 2.0 5 votes vote down vote up
private synchronized void writeToDOM(Node target, short type) {
    Document futureOwner = (type == XSAnnotation.W3C_DOM_ELEMENT) ?
            target.getOwnerDocument() : (Document)target;
    DOMParser parser = fGrammar.getDOMParser();
    StringReader aReader = new StringReader(fData);
    InputSource aSource = new InputSource(aReader);
    try {
        parser.parse(aSource);
    }
    catch (SAXException e) {
        // this should never happen!
        // REVISIT:  what to do with this?; should really not
        // eat it...
    }
    catch (IOException i) {
        // ditto with above
    }
    Document aDocument = parser.getDocument();
    parser.dropDocumentReferences();
    Element annotation = aDocument.getDocumentElement();
    Node newElem = null;
    if (futureOwner instanceof CoreDocumentImpl) {
        newElem = futureOwner.adoptNode(annotation);
        // adoptNode will return null when the DOM implementations are not compatible.
        if (newElem == null) {
            newElem = futureOwner.importNode(annotation, true);
        }
    }
    else {
        newElem = futureOwner.importNode(annotation, true);
    }
    target.insertBefore(newElem, target.getFirstChild());
}
 
Example #20
Source File: DocumentBuilderFactoryImpl.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Allows the user to retrieve specific attributes on the underlying
 * implementation.
 */
public Object getAttribute(String name)
    throws IllegalArgumentException
{
    // See if it's in the attributes Map
    if (attributes != null) {
        Object val = attributes.get(name);
        if (val != null) {
            return val;
        }
    }

    DOMParser domParser = null;
    try {
        // We create a dummy DocumentBuilderImpl in case the attribute
        // name is not one that is in the attributes map.
        domParser =
            new DocumentBuilderImpl(this, attributes, features).getDOMParser();
        return domParser.getProperty(name);
    } catch (SAXException se1) {
        // assert(name is not recognized or not supported), try feature
        try {
            boolean result = domParser.getFeature(name);
            // Must have been a feature
            return result ? Boolean.TRUE : Boolean.FALSE;
        } catch (SAXException se2) {
            // Not a property or a feature
            throw new IllegalArgumentException(se1.getMessage());
        }
    }
}
 
Example #21
Source File: XSAnnotationImpl.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
private synchronized void writeToDOM(Node target, short type) {
    Document futureOwner = (type == XSAnnotation.W3C_DOM_ELEMENT) ?
            target.getOwnerDocument() : (Document)target;
    DOMParser parser = fGrammar.getDOMParser();
    StringReader aReader = new StringReader(fData);
    InputSource aSource = new InputSource(aReader);
    try {
        parser.parse(aSource);
    }
    catch (SAXException e) {
        // this should never happen!
        // REVISIT:  what to do with this?; should really not
        // eat it...
    }
    catch (IOException i) {
        // ditto with above
    }
    Document aDocument = parser.getDocument();
    parser.dropDocumentReferences();
    Element annotation = aDocument.getDocumentElement();
    Node newElem = null;
    if (futureOwner instanceof CoreDocumentImpl) {
        newElem = futureOwner.adoptNode(annotation);
        // adoptNode will return null when the DOM implementations are not compatible.
        if (newElem == null) {
            newElem = futureOwner.importNode(annotation, true);
        }
    }
    else {
        newElem = futureOwner.importNode(annotation, true);
    }
    target.insertBefore(newElem, target.getFirstChild());
}
 
Example #22
Source File: DocumentBuilderFactoryImpl.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Allows the user to retrieve specific attributes on the underlying
 * implementation.
 */
public Object getAttribute(String name)
    throws IllegalArgumentException
{
    // See if it's in the attributes Map
    if (attributes != null) {
        Object val = attributes.get(name);
        if (val != null) {
            return val;
        }
    }

    DOMParser domParser = null;
    try {
        // We create a dummy DocumentBuilderImpl in case the attribute
        // name is not one that is in the attributes map.
        domParser =
            new DocumentBuilderImpl(this, attributes, features).getDOMParser();
        return domParser.getProperty(name);
    } catch (SAXException se1) {
        // assert(name is not recognized or not supported), try feature
        try {
            boolean result = domParser.getFeature(name);
            // Must have been a feature
            return result ? Boolean.TRUE : Boolean.FALSE;
        } catch (SAXException se2) {
            // Not a property or a feature
            throw new IllegalArgumentException(se1.getMessage());
        }
    }
}
 
Example #23
Source File: XSAnnotationImpl.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
private synchronized void writeToDOM(Node target, short type) {
    Document futureOwner = (type == XSAnnotation.W3C_DOM_ELEMENT) ?
            target.getOwnerDocument() : (Document)target;
    DOMParser parser = fGrammar.getDOMParser();
    StringReader aReader = new StringReader(fData);
    InputSource aSource = new InputSource(aReader);
    try {
        parser.parse(aSource);
    }
    catch (SAXException e) {
        // this should never happen!
        // REVISIT:  what to do with this?; should really not
        // eat it...
    }
    catch (IOException i) {
        // ditto with above
    }
    Document aDocument = parser.getDocument();
    parser.dropDocumentReferences();
    Element annotation = aDocument.getDocumentElement();
    Node newElem = null;
    if (futureOwner instanceof CoreDocumentImpl) {
        newElem = futureOwner.adoptNode(annotation);
        // adoptNode will return null when the DOM implementations are not compatible.
        if (newElem == null) {
            newElem = futureOwner.importNode(annotation, true);
        }
    }
    else {
        newElem = futureOwner.importNode(annotation, true);
    }
    target.insertBefore(newElem, target.getFirstChild());
}
 
Example #24
Source File: DocumentBuilderFactoryImpl.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Allows the user to retrieve specific attributes on the underlying
 * implementation.
 */
public Object getAttribute(String name)
    throws IllegalArgumentException
{
    // See if it's in the attributes Hashtable
    if (attributes != null) {
        Object val = attributes.get(name);
        if (val != null) {
            return val;
        }
    }

    DOMParser domParser = null;
    try {
        // We create a dummy DocumentBuilderImpl in case the attribute
        // name is not one that is in the attributes hashtable.
        domParser =
            new DocumentBuilderImpl(this, attributes, features).getDOMParser();
        return domParser.getProperty(name);
    } catch (SAXException se1) {
        // assert(name is not recognized or not supported), try feature
        try {
            boolean result = domParser.getFeature(name);
            // Must have been a feature
            return result ? Boolean.TRUE : Boolean.FALSE;
        } catch (SAXException se2) {
            // Not a property or a feature
            throw new IllegalArgumentException(se1.getMessage());
        }
    }
}
 
Example #25
Source File: XSAnnotationImpl.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
private synchronized void writeToDOM(Node target, short type) {
    Document futureOwner = (type == XSAnnotation.W3C_DOM_ELEMENT) ?
            target.getOwnerDocument() : (Document)target;
    DOMParser parser = fGrammar.getDOMParser();
    StringReader aReader = new StringReader(fData);
    InputSource aSource = new InputSource(aReader);
    try {
        parser.parse(aSource);
    }
    catch (SAXException e) {
        // this should never happen!
        // REVISIT:  what to do with this?; should really not
        // eat it...
    }
    catch (IOException i) {
        // ditto with above
    }
    Document aDocument = parser.getDocument();
    parser.dropDocumentReferences();
    Element annotation = aDocument.getDocumentElement();
    Node newElem = null;
    if (futureOwner instanceof CoreDocumentImpl) {
        newElem = futureOwner.adoptNode(annotation);
        // adoptNode will return null when the DOM implementations are not compatible.
        if (newElem == null) {
            newElem = futureOwner.importNode(annotation, true);
        }
    }
    else {
        newElem = futureOwner.importNode(annotation, true);
    }
    target.insertBefore(newElem, target.getFirstChild());
}
 
Example #26
Source File: DocumentBuilderFactoryImpl.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Allows the user to retrieve specific attributes on the underlying
 * implementation.
 */
public Object getAttribute(String name)
    throws IllegalArgumentException
{
    // See if it's in the attributes Hashtable
    if (attributes != null) {
        Object val = attributes.get(name);
        if (val != null) {
            return val;
        }
    }

    DOMParser domParser = null;
    try {
        // We create a dummy DocumentBuilderImpl in case the attribute
        // name is not one that is in the attributes hashtable.
        domParser =
            new DocumentBuilderImpl(this, attributes, features).getDOMParser();
        return domParser.getProperty(name);
    } catch (SAXException se1) {
        // assert(name is not recognized or not supported), try feature
        try {
            boolean result = domParser.getFeature(name);
            // Must have been a feature
            return result ? Boolean.TRUE : Boolean.FALSE;
        } catch (SAXException se2) {
            // Not a property or a feature
            throw new IllegalArgumentException(se1.getMessage());
        }
    }
}
 
Example #27
Source File: DocumentBuilderFactoryImpl.java    From jdk1.8-source-analysis with Apache License 2.0 5 votes vote down vote up
/**
 * Allows the user to retrieve specific attributes on the underlying
 * implementation.
 */
public Object getAttribute(String name)
    throws IllegalArgumentException
{
    // See if it's in the attributes Map
    if (attributes != null) {
        Object val = attributes.get(name);
        if (val != null) {
            return val;
        }
    }

    DOMParser domParser = null;
    try {
        // We create a dummy DocumentBuilderImpl in case the attribute
        // name is not one that is in the attributes map.
        domParser =
            new DocumentBuilderImpl(this, attributes, features).getDOMParser();
        return domParser.getProperty(name);
    } catch (SAXException se1) {
        // assert(name is not recognized or not supported), try feature
        try {
            boolean result = domParser.getFeature(name);
            // Must have been a feature
            return result ? Boolean.TRUE : Boolean.FALSE;
        } catch (SAXException se2) {
            // Not a property or a feature
            throw new IllegalArgumentException(se1.getMessage());
        }
    }
}
 
Example #28
Source File: XSAnnotationImpl.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
private synchronized void writeToDOM(Node target, short type) {
    Document futureOwner = (type == XSAnnotation.W3C_DOM_ELEMENT) ?
            target.getOwnerDocument() : (Document)target;
    DOMParser parser = fGrammar.getDOMParser();
    StringReader aReader = new StringReader(fData);
    InputSource aSource = new InputSource(aReader);
    try {
        parser.parse(aSource);
    }
    catch (SAXException e) {
        // this should never happen!
        // REVISIT:  what to do with this?; should really not
        // eat it...
    }
    catch (IOException i) {
        // ditto with above
    }
    Document aDocument = parser.getDocument();
    parser.dropDocumentReferences();
    Element annotation = aDocument.getDocumentElement();
    Node newElem = null;
    if (futureOwner instanceof CoreDocumentImpl) {
        newElem = futureOwner.adoptNode(annotation);
        // adoptNode will return null when the DOM implementations are not compatible.
        if (newElem == null) {
            newElem = futureOwner.importNode(annotation, true);
        }
    }
    else {
        newElem = futureOwner.importNode(annotation, true);
    }
    target.insertBefore(newElem, target.getFirstChild());
}
 
Example #29
Source File: WebContentAssemblingService.java    From abixen-platform with GNU Lesser General Public License v2.1 5 votes vote down vote up
private Document getParsedXml(final String dataForContent) {
    final DOMParser parser = new DOMParser();
    try {
        parser.parse(new InputSource(new java.io.StringReader(dataForContent)));
        return parser.getDocument();
    } catch (SAXException | IOException e) {
        throw new PlatformRuntimeException("Can't parse structure for advanced web content. Please check configuration.");
    }
}
 
Example #30
Source File: DocumentBuilderFactoryImpl.java    From Bytecoder with Apache License 2.0 5 votes vote down vote up
/**
 * Allows the user to retrieve specific attributes on the underlying
 * implementation.
 */
public Object getAttribute(String name)
    throws IllegalArgumentException
{
    // See if it's in the attributes Map
    if (attributes != null) {
        Object val = attributes.get(name);
        if (val != null) {
            return val;
        }
    }

    DOMParser domParser = null;
    try {
        // We create a dummy DocumentBuilderImpl in case the attribute
        // name is not one that is in the attributes map.
        domParser =
            new DocumentBuilderImpl(this, attributes, features).getDOMParser();
        return domParser.getProperty(name);
    } catch (SAXException se1) {
        // assert(name is not recognized or not supported), try feature
        try {
            boolean result = domParser.getFeature(name);
            // Must have been a feature
            return result ? Boolean.TRUE : Boolean.FALSE;
        } catch (SAXException se2) {
            // Not a property or a feature
            throw new IllegalArgumentException(se1.getMessage());
        }
    }
}