You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xalan.apache.org by dl...@locus.apache.org on 2000/09/19 21:58:16 UTC

cvs commit: xml-xalan/java/samples/ApplyXPath ApplyXPath.java

dleslie     00/09/19 12:58:16

  Modified:    java/samples/ApplyXPath ApplyXPath.java
  Log:
  conditionaly serialize XPath result.
  
  Revision  Changes    Path
  1.2       +10 -5     xml-xalan/java/samples/ApplyXPath/ApplyXPath.java
  
  Index: ApplyXPath.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/samples/ApplyXPath/ApplyXPath.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ApplyXPath.java	2000/09/19 19:41:23	1.1
  +++ ApplyXPath.java	2000/09/19 19:58:15	1.2
  @@ -157,11 +157,16 @@
   	  {
   		while ((n = nl.nextNode())!= null)
   		{
  -    	  if (n.getNodeValue() == null)
  -	        System.out.println(n.getNodeName());
  -	      else
  -	        System.out.println(n.getNodeName()+ " -- " + n.getNodeValue());
  -		  // XMLSerializer does not work.
  +		  // XMLSerializer does not fully work.		  
  +		  XMLSerializer xmlser = new XMLSerializer(System.out, new OutputFormat());
  +		  if (n.getNodeType() == n.DOCUMENT_NODE)
  +			xmlser.serialize((Document)n);
  +		  else if (n.getNodeType() == n.ELEMENT_NODE)
  +			xmlser.serialize((Element)n);
  +		  else
  +			  System.out.println
  +				  ("XMLSerializer cannot serialize: " + n.getNodeName()+ " -- " + n.getNodeValue());
  +		  
   		  //TreeWalker tw = new TreeWalker(new XMLSerializer(System.out, new OutputFormat()));
             //tw.traverse(n);
   		}