Menu

ContentHandler - saxon vs xalan

Help
2001-07-11
2012-10-08
  • Daniel Parker

    Daniel Parker - 2001-07-11

    Since saxon does not currently support source to source transformations :-(, I've had to switch to xalan for now.  In doing so, I've noticed some differences between how the two products receive SAX feeds through ContentHandlers.  In the case of no namespaces, saxon requires an empty string for the namespace uri and a value for the local name; xalan requires an empty string for the namespace uri and a (non-prefixed) value for the qualified name.  The xerces javadoc for ContentHandler supports the xalan practice.  Any comments?

    Setting both the local name and the qualified name works for both, but I'm not sure that that's right.

    Regards,
    Daniel Parker

     
    • Michael Kay

      Michael Kay - 2001-07-11

      I'm not sure what you mean by saying "Saxon doesn't support Source to Source transformations". (Of course it doesn't, it only supports Source to Result transformations!)

      When Saxon takes input from a SAX source, it requires that the parser support the SAX2-defined features http://xml.org/sax/features/namespaces = true, http://xml.org/sax/features/namespace-prefixes = false. These are the default settings and every SAX2-conformant parser is required to support them. With these settings, the parser must call the ContentHandler with the unprefixed value for the local name. If you supply anything different, then you're probably ignoring the SAX2 features requested by Saxon, which means your parser is not SAX2 compliant. Xalan is of course at liberty to request different SAX2 features.

       
    • Daniel Parker

      Daniel Parker - 2001-07-11

      Sorry, what I meant is that attempting to transform a source into a result without a stylesheet doesn't work in saxon.  (I've reported that as a bug in the mailing lists on at least three separate occaisons; it never seemed to make the acknowledged list :-)  More particularly,

      Source to _result_ transform fails

      TransformerFactoryImpl transformerFactory = new
      TransformerFactoryImpl();

      Transformer transformer =
      transformerFactory.newTransformer();

      SAXSource source; // Valid SAX source

      DOMResult result = new DOMResult();

      transformer.transform(source,result);

      Node node = result.getNode();

      NodeList list = node.getChildNodes();

      list.length() is always zero

      Xalan handles this correctly.

      Regards,
      Daniel Parker

       
    • Michael Kay

      Michael Kay - 2001-07-13

      Bug now identified and fixed: 440992