Examples of NodeFactory


Examples of nu.xom.NodeFactory

   * method does not look across multiple Text nodes.
   *
   * @return a node factory
   */
  public static NodeFactory getIgnoreWhitespaceOnlyTextNodeFactory() {
    return new NodeFactory() {
      private final Nodes NONE = new Nodes();
     
      public Nodes makeText(String text) {
        return Normalizer.isWhitespaceOnly(text) ?
          NONE :
View Full Code Here

Examples of nu.xom.NodeFactory

    if (child == null)
      throw new IllegalArgumentException("child must not be null");
    if (log == null)
      throw new IllegalArgumentException("logStream must not be null");
   
    return new NodeFactory() {   
      private int level = 0;
     
      public Nodes makeAttribute(String name, String URI, String value, Attribute.Type type) {
        log("", new Attribute(name, URI, value, type));
        return child.makeAttribute(name, URI, value, type);
View Full Code Here

Examples of nu.xom.NodeFactory

   * many, but not all XML use cases (round-tripping).
   *
   * @return a node factory
   */
  public static NodeFactory getTextTrimmingNodeFactory() {
    return new NodeFactory() {
      private final Nodes NONE = new Nodes();
     
      public Nodes makeText(String text) {
        text = Normalizer.trim(text);
        return text.length() == 0 ? NONE : super.makeText(text);
View Full Code Here

Examples of nu.xom.NodeFactory

   * empty document instead. This improves validation performance.
   *
   * @return a node factory
   */
  public static NodeFactory getNullNodeFactory() {
    return new NodeFactory() {
      private final Nodes NONE = new Nodes();
           
      public Nodes makeAttribute(String name, String URI, String value, Attribute.Type type) {
        return NONE;
      }
View Full Code Here

Examples of nu.xom.NodeFactory

   
    /*
     * Buffers a start tag until attributes and namespaces have been attached
     * by the Builder, and only then calls serializer.writeStartTag(Elem).
     */
    return new NodeFactory() {
     
      private Element buffer = null;
      private final Nodes NONE = new Nodes();
      private final NodeBuilder nodeBuilder = new NodeBuilder();
           
View Full Code Here

Examples of nu.xom.NodeFactory

  }
   
  private void run(File file) throws Exception {
    Document expected = getBuilder().build(file);
   
    NodeFactory factory = new NodeFactory();
    XMLInputFactory staxFactory = createXMLInputFactory();
    Document actual = StaxUtil.createBuilder(staxFactory, factory).build(file);
   
    IOTestUtil.xomAssertEquals(expected, actual);
    IOTestUtil.canonicalAssertEquals(expected, actual);   
View Full Code Here

Examples of nu.xom.NodeFactory

   *             if no XSLTransform can be obtained for the given stylesheet;
   *             in particular when the supplied stylesheet is not
   *             syntactically correct XSLT
   */
  protected XSLTransform newTransform(Document stylesheet, TransformerFactory transformerFactory) throws XSLException {
    return new XSLTransform(stylesheet, new NodeFactory(), transformerFactory);
  }
View Full Code Here

Examples of nu.xom.NodeFactory

  private final Element DUMMY = new Element("dummy");
 
  public static void main(String[] args) throws Exception {
    System.out.println("\nTree structure summary:");
    System.out.println("***********************\n");
    NodeFactory factory = new TreeStructureCollector();
    Document summary = new Builder(factory).build(new File(args[0]));
    Serializer ser = new Serializer(System.out);
    ser.setIndent(4);
    ser.write(summary);
//    System.out.println(XOMUtil.toPrettyXML(summary));
View Full Code Here

Examples of nu.xom.NodeFactory

    return x.indexOf(y) >= 0;
  }

  protected static Builder getBuilder() {
//    if (!ENABLE_BUILDER_POOL) return new Builder();
    if (!ENABLE_BUILDER_POOL) return new Builder(new NodeFactory() {});
    return BuilderPool.GLOBAL_POOL.getBuilder(false);
  }
View Full Code Here

Examples of nu.xom.NodeFactory

      }

     
      // bnux and XOM
      BinaryXMLCodec codec = new BinaryXMLCodec();
      NodeFactory bnuxFactory = null;
      if (mode.startsWith("bnux")) {
        if (mode.indexOf("NNF") >= 0) {
          bnuxFactory = XOMUtil.getNullNodeFactory();
        }
      }

      Builder builder = new Builder();
//      Builder builder = BuilderPool.GLOBAL_POOL.getBuilder(false);
      if (mode.equals("xom-V")) {
        builder = new Builder(new NodeFactory() {});
      }
      if (mode.equals("xom-NNF")) {
        builder = new Builder(XOMUtil.getNullNodeFactory());
      }
     
      // saxon
      StaticQueryContext context = null;
      Transformer saxonSerializer = null;
      if (mode.equals("saxon")) {
        context = new StaticQueryContext(new Configuration());
        String clazz = "net.sf.saxon.TransformerFactoryImpl";
        System.setProperty("javax.xml.transform.TransformerFactory", clazz);
        saxonSerializer = TransformerFactory.newInstance().newTransformer();
      }
     
      // DOM
      DocumentBuilder domBuilder = null;
      Transformer domSerializer = null;
      if (mode.equals("dom")) {
        DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
        factory.setNamespaceAware(true);
        factory.setAttribute("http://apache.org/xml/features/dom/defer-node-expansion", Boolean.FALSE);
        domBuilder = factory.newDocumentBuilder();
        String clazz = "com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl";
//        String clazz = "org.apache.xalan.processor.TransformerFactoryImpl";
        System.setProperty("javax.xml.transform.TransformerFactory", clazz);
        domSerializer = TransformerFactory.newInstance().newTransformer();
        System.err.println(domSerializer.getClass().getName());
      }
     
      // FastInfoSet
      Object fiSerializer = null;
//      XMLStreamWriter fiStaxSerializer = null;
      Builder fiBuilder = null
      Method fiMethod = null;
     
      XMLStreamReader fistaxReader = null;
      Method fistaxMethod = null;
      if (mode.startsWith("fi")) {
        NodeFactory factory = null;
        if (mode.indexOf("NNF") >= 0) factory = XOMUtil.getNullNodeFactory();
        XMLReader parser = (XMLReader) Class.forName("com.sun.xml.fastinfoset.sax.SAXDocumentParser").newInstance();
        fiBuilder = new Builder(parser, false, factory);
       
        if (mode.indexOf("stax") >= 0) {
          fiSerializer = (XMLStreamWriter) Class.forName("com.sun.xml.fastinfoset.stax.StAXDocumentSerializer").newInstance();       
        } else {
          fiSerializer = (ContentHandler) Class.forName("com.sun.xml.fastinfoset.sax.SAXDocumentSerializer").newInstance();
        }
       
        if (mode.startsWith("fi1")) { // enable "full indexing"
          Method method;
          method = fiSerializer.getClass().getMethod(
              "setAttributeValueSizeLimit", new Class[] {Integer.TYPE});
          method.invoke(fiSerializer, new Object[] {new Integer(Integer.MAX_VALUE)});
          method = fiSerializer.getClass().getMethod(
              "setCharacterContentChunkSizeLimit", new Class[] {Integer.TYPE});
          method.invoke(fiSerializer, new Object[] {new Integer(Integer.MAX_VALUE)});
        }
       
        fiMethod = fiSerializer.getClass().getMethod(
            "setOutputStream", new Class[] { OutputStream.class});
       
        if (mode.indexOf("stax") >= 0) {
          fistaxReader = (XMLStreamReader) Class.forName("com.sun.xml.fastinfoset.stax.StAXDocumentParser").newInstance();
          fistaxMethod = fistaxReader.getClass().getMethod(
              "setInputStream", new Class[] { InputStream.class});
        }
      }
     
      // StAX
      Builder staxBuilder = null;
      if (mode.indexOf("stax") >= 0) {
        NodeFactory factory = null;
        if (mode.indexOf("NNF") >= 0) factory = XOMUtil.getNullNodeFactory();
        staxBuilder = StaxUtil.createBuilder(staxInputFactory, factory);
      }
     
      for (int j=5; j < args.length; j++) {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.