Package org.codehaus.staxmate.dom

Examples of org.codehaus.staxmate.dom.DOMConverter


       
      StringTools.append(annotationBeginning, Character.valueOf('>'),
          Character.valueOf('\n'), annotation.getNonRDFannotation(),
          whiteSpaces, "</annotation>", Character.valueOf('\n'));

      DOMConverter converter = new DOMConverter();
     
      String annotationString = annotationBeginning.toString()
          .replaceAll("&", "&amp;");
      // here indent gets lost.
      Document domDocument = null;
      boolean domConversionDone = false;

      try {
        domDocument = JAXPFacade.getInstance().create(
            new BufferedReader(new StringReader(annotationString)),  allNamespacesDefined);
        domConversionDone = true;
      } catch (SAXException e) {
        e.printStackTrace();
        // TODO: log error or send SBMLException

        logger.warn("Cannot parse the following XML\n@" + annotationString + "@");
        logger.warn("NonRDFannotation =\n@" + annotation.getNonRDFannotation() + "@");
       
        // trying to read the XML without namespace awareness as the XML can be wrong and we still want to
        // write it back as it is.
        if (allNamespacesDefined) {
         
          try {
            domDocument = JAXPFacade.getInstance().create(
                new BufferedReader(new StringReader(annotationString))false);
            domConversionDone = true;
          } catch (SAXException e2) {
            e.printStackTrace();
            // TODO: log error or send SBMLException
          }
        }
      } finally {
        if (domConversionDone) { 
          converter.writeFragment(domDocument.getFirstChild()
              .getChildNodes(), writer);
        }
      }
    } else {
      writer.writeCharacters("\n");
View Full Code Here


       
      StringTools.append(annotationBeginning, Character.valueOf('>'),
          Character.valueOf('\n'), annotation.getNonRDFannotation(),
          whiteSpaces, "</annotation>", Character.valueOf('\n'));

      DOMConverter converter = new DOMConverter();
     
      String annotationString = annotationBeginning.toString()
          .replaceAll("&", "&amp;");
      // here indent gets lost.
      Document domDocument = null;
      boolean domConversionDone = false;

      try {
        domDocument = JAXPFacade.getInstance().create(
            new BufferedReader(new StringReader(annotationString)),  allNamespacesDefined);
        domConversionDone = true;
      } catch (SAXException e) {
        e.printStackTrace();
        // TODO : log error or send SBMLException

        logger.warn("Cannot parse the following XML\n@" + annotationString + "@");
        logger.warn("NonRDFannotation =\n@" + annotation.getNonRDFannotation() + "@");
       
        // trying to read the XML without namespace awareness as the XML can be wrong and we still want to
        // write it back as it is.
        if (allNamespacesDefined) {
         
          try {
            domDocument = JAXPFacade.getInstance().create(
                new BufferedReader(new StringReader(annotationString))false);
            domConversionDone = true;
          } catch (SAXException e2) {
            e.printStackTrace();
            // TODO : log error or send SBMLException
          }
        }
      } finally {
        if (domConversionDone) {
          converter.writeFragment(domDocument.getFirstChild()
              .getChildNodes(), writer);
        }
      }
    } else {
      writer.writeCharacters("\n");
View Full Code Here

       
      StringTools.append(annotationBeginning, Character.valueOf('>'),
          Character.valueOf('\n'), annotation.getNonRDFannotation(),
          whiteSpaces, "</annotation>", Character.valueOf('\n'));

      DOMConverter converter = new DOMConverter();
     
      String annotationString = annotationBeginning.toString()
          .replaceAll("&", "&amp;");
      // here indent gets lost.
      Document domDocument = null;
      boolean domConversionDone = false;

      try {
        domDocument = JAXPFacade.getInstance().create(
            new BufferedReader(new StringReader(annotationString)),  allNamespacesDefined);
        domConversionDone = true;
      } catch (SAXException e) {
        e.printStackTrace();
        // TODO : log error or send SBMLException

        logger.warn("Cannot parse the following XML\n@" + annotationString + "@");
        logger.warn("NonRDFannotation =\n@" + annotation.getNonRDFannotation() + "@");
       
        // trying to read the XML without namespace awareness as the XML can be wrong and we still want to
        // write it back as it is.
        if (allNamespacesDefined) {
         
          try {
            domDocument = JAXPFacade.getInstance().create(
                new BufferedReader(new StringReader(annotationString))false);
            domConversionDone = true;
          } catch (SAXException e2) {
            e.printStackTrace();
            // TODO : log error or send SBMLException
          }
        }
      } finally {
        if (domConversionDone) {
          converter.writeFragment(domDocument.getFirstChild()
              .getChildNodes(), writer);
        }
      }
    } else {
      writer.writeCharacters("\n");
View Full Code Here

   
    protected Element convertToElement(Source source) {
        if (source instanceof StAXSource) {
            final StAXSource staxSource = (StAXSource)source;
           
            final DOMConverter domConverter = new DOMConverter();
            final Document document;
            try {
                XMLStreamReader xmlStreamReader = staxSource.getXMLStreamReader();
                if (xmlStreamReader == null) {
                    final XMLEventReader xmlEventReader = staxSource.getXMLEventReader();
                    xmlStreamReader = new FixedXMLEventStreamReader(xmlEventReader);
                }
               
                document = domConverter.buildDocument(xmlStreamReader);
            }
            catch (XMLStreamException e) {
                throw new RuntimeException("Failed to parse StAX Reader into Dom4J Element", e);
            }
            final DOMReader domReader = new DOMReader();
View Full Code Here

TOP

Related Classes of org.codehaus.staxmate.dom.DOMConverter

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.