Package org.apache.xerces.parsers

Examples of org.apache.xerces.parsers.DOMParser


   
    //---------------------------------------------------------------------------------------------
   
    private static Document dom_from_xml( String xml throws Exception
    {
        DOMParser parser = new DOMParser();
        parser.parse( new org.xml.sax.InputSource( new StringReader( xml ) ) );
           
        return parser.getDocument();
    }
View Full Code Here


   * @param pstrXPathExpr = if null, the full XML-String is loaded
   */
  public Properties LoadXML(JSXMLFile pobjXMLFile, String pstrXPathExpr) {
    @SuppressWarnings("unused")
    final String conMethodName = conClassName + "::LoadXML";
    DOMParser parser = new DOMParser();
    Properties objProp = new Properties();
    try {
      parser.setFeature("http://xml.org/sax/features/validation", false);
      // The parser will validate the document only if a grammar is specified.
      // parser.setFeature("http://xml.org/sax/features/validation/dynamic", true);
    }
    catch (Exception e) {
      e.printStackTrace();
      throw new JobSchedulerException(String.format("SAXException ", pobjXMLFile.getAbsolutePath()));
    }
    try {
      // parser.parse(new ByteArrayInputStream(pstrXMLAsString.getBytes()));
      parser.parse(pobjXMLFile.getAbsolutePath());
      Document document = parser.getDocument();
      if (isEmpty(pstrXPathExpr) == true) {
        traverse(document, objProp);
      }
      else {
        SOSXMLXPath xPath = new SOSXMLXPath(pobjXMLFile.getAbsolutePath());
View Full Code Here

   * @param reader
   * @return
   */
  public Collection readDOM (Reader reader) {
    Collection collection = new java.util.ArrayList ();
    DOMParser parser = new DOMParser ();
    try {
        parser.setErrorHandler(new MyErrorListener (_output));
      parser.parse (new InputSource(reader));
      Document doc = parser.getDocument();
      collection.add(doc.getDocumentElement());     
    } catch (Exception ex) {
      System.out.println ("XMLUtility::readDOM - " + ex);
    }
    return collection;
View Full Code Here

    /**
     * Test createRuleExecutionSet from DOM.
     */
    public void testCreateFromElement( ) throws Exception
    {
        DOMParser parser = new DOMParser( );
        Document doc = null;
        try
        {
            parser.parse( new InputSource(
                RuleEngineTestBase.class.getResourceAsStream( bindUri ) ) );
            doc = parser.getDocument( );
        }
        catch ( SAXException e )
        {
            fail( "could not parse incoming data stream: " + e );
        }
View Full Code Here

    }
   
    /** Set up the GISDisplay with the given configuration file */
    public static void readConfig(GISDisplay inDisplay, String inFileName) throws Exception{
        // read the XML document
        DOMParser parser = new DOMParser();
        parser.parse("file:///"+inFileName);
        Document tempDocument= parser.getDocument();
        Element tempRootElement = tempDocument.getDocumentElement();
        if (tempRootElement.getTagName().equals("GISToolkit")){
            gistoolkit.common.Node tempNode = getNode(tempRootElement);
            gistoolkit.common.Node tempDisplayNode = tempNode.getChild("GISDisplay");
            inDisplay.setNode(tempDisplayNode);
View Full Code Here

    }

    /** Set up the Server with the given configuration file. */
    public static void readConfig(Server inServer, String inFileName) throws Exception {
        // read the XML document
        DOMParser parser = new DOMParser();
        parser.parse(inFileName);
        Document tempDocument= parser.getDocument();
        Element tempRootElement = tempDocument.getDocumentElement();
        if (tempRootElement.getTagName().equals("GISToolkit")){
            gistoolkit.common.Node tempNode = getNode(tempRootElement);
            gistoolkit.common.Node tempServerNode = tempNode.getChild("GISServer");
            inServer.setNode(tempServerNode);
View Full Code Here

    }

    /** Reads configuration information from the given file. */
    public static gistoolkit.common.Node readConfig( String inFileName) throws Exception {
        // read the XML document
        DOMParser parser = new DOMParser();
        parser.parse(inFileName);
        Document tempDocument= parser.getDocument();
        Element tempRootElement = tempDocument.getDocumentElement();
        if (tempRootElement.getTagName().equals("GISToolkit")){
            gistoolkit.common.Node tempNode = getNode(tempRootElement);
            gistoolkit.common.Node[] tempNodes = tempNode.getChildren();
            if (tempNodes.length > 0){
View Full Code Here

    }
   
    /** Read an XML document from the given location, and parse it into a node tree */
    public static gistoolkit.common.Node getXML(String inLocation) throws Exception{
        // read the XML document
        DOMParser parser = new DOMParser();
        parser.setFeature("http://xml.org/sax/features/validation", false);
        parser.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false);
        parser.parse(inLocation);
        Document tempDocument= parser.getDocument();
        Element tempRootElement = tempDocument.getDocumentElement();
        gistoolkit.common.Node tempNode = getNode(tempRootElement);
        return tempNode;
    }
View Full Code Here

    }
    else
    {
      Document document = null;
      try {     
        DOMParser parser = new DOMParser();
        parser.parse(new InputSource(new ByteArrayInputStream(content.getBytes())));
        document = parser.getDocument();     
      } catch (Throwable e) {
        XcapException e1 = new XcapException("Unable to read XML content",
            HttpServletResponse.SC_CONFLICT, e);
        StringBuffer sb = new StringBuffer();
        sb.append(XcapException.XCAP_ERROR_HEADER);
View Full Code Here

    {
      if (_document == null)
      {
        try
        {
          DOMParser parser = new DOMParser();
          parser.parse(new InputSource(new FileInputStream(_file)));
          _document = parser.getDocument();
        }
        catch (Exception e)
        {
          throw XcapException.newInternalError(e);
        }
View Full Code Here

TOP

Related Classes of org.apache.xerces.parsers.DOMParser

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.