You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by tw...@apache.org on 2002/01/22 20:39:11 UTC

cvs commit: xml-xerces/java/samples/dom DOMAddLines.java

twl         02/01/22 11:39:11

  Modified:    java/samples/dom DOMAddLines.java
  Log:
  Update to DOM L3
  
  Revision  Changes    Path
  1.5       +21 -14    xml-xerces/java/samples/dom/DOMAddLines.java
  
  Index: DOMAddLines.java
  ===================================================================
  RCS file: /home/cvs/xml-xerces/java/samples/dom/DOMAddLines.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- DOMAddLines.java	23 Aug 2001 00:35:17 -0000	1.4
  +++ DOMAddLines.java	22 Jan 2002 19:39:11 -0000	1.5
  @@ -61,9 +61,14 @@
   
   import org.apache.xerces.dom.NodeImpl;
   import org.apache.xerces.parsers.DOMParser;
  +import org.apache.xerces.xni.Augmentations;
   import org.apache.xerces.xni.QName;
   import org.apache.xerces.xni.XMLAttributes;
  +import org.apache.xerces.xni.XMLLocator;
   import org.apache.xerces.xni.XMLString;
  +import org.apache.xerces.xni.XNIException;
  +
  +import org.apache.xerces.dom3.Node3;
   
   import org.w3c.dom.Attr;
   import org.w3c.dom.Document;
  @@ -85,14 +90,15 @@
    * - How to attach user defined Objects to Nodes using method setUserData
    * This example relies on the following:
    * - Turning off the "fast" DOM so we can use set expansion to FULL 
  - * @version $Id: DOMAddLines.java,v 1.4 2001/08/23 00:35:17 lehors Exp $
  + * @version $Id: DOMAddLines.java,v 1.5 2002/01/22 19:39:11 twl Exp $
    */
   
   public class DOMAddLines extends DOMParser  {
   
      /** Print writer. */
      private PrintWriter out;
  -   static private boolean NotIncludeIgnorableWhiteSpaces = false; 
  +   static private boolean NotIncludeIgnorableWhiteSpaces = false;
  +   private XMLLocator locator; 
   
   
      public DOMAddLines( String inputName ) {
  @@ -116,7 +122,7 @@
            return;
         }
   
  -      String lineRowColumn = (String ) ((NodeImpl) node).getUserData();
  +      String lineRowColumn = (String ) ((NodeImpl) node).getUserData("startLine");
   
         int type = node.getNodeType();
         switch ( type ) {
  @@ -232,9 +238,9 @@
   
      /*   We override startElement callback  from DocumentHandler */
   
  -   public void startElement(QName elementQName, XMLAttributes attrList) 
  -    throws SAXException {
  -      super.startElement(elementQName, attrList);
  +   public void startElement(QName elementQName, XMLAttributes attrList, Augmentations augs) 
  +    throws XNIException {
  +      super.startElement(elementQName, attrList, augs);
   
         NodeImpl node = null;
         try {
  @@ -247,18 +253,19 @@
         }
         //NodeImpl node = (NodeImpl)getCurrentNode();       // Get current node
         if( node != null )
  -          node.setUserData(  String.valueOf( fEntityManager.getEntityScanner().getLineNumber() ) ); // Save location String into node
  +          node.setUserData( "startLine", String.valueOf( locator.getLineNumber() ), null ); // Save location String into node
      } //startElement 
   
      /* We override startDocument callback from DocumentHandler */
   
  -   public void startDocument() throws SAXException {
  +   public void startDocument(XMLLocator locator, String encoding, Augmentations augs) throws XNIException {
        //super.startDocument( versionIndex, encodingIndex,
        //                               standAloneIndex);
  -     super.startDocument();
  -     NodeImpl node = null ;
  +     super.startDocument(locator, encoding, augs);
  +     this.locator = locator;
  +     Node3 node = null ;
         try {
  -      node = (NodeImpl) this.getProperty( "http://apache.org/xml/properties/dom/current-element-node" );
  +      node = (Node3) this.getProperty( "http://apache.org/xml/properties/dom/current-element-node" );
         //System.out.println( "The node = " + node );
         }
        catch( org.xml.sax.SAXException ex )
  @@ -268,14 +275,14 @@
        
   //     NodeImpl node = (NodeImpl)getCurrentNode();       // Get current node
        if( node != null )
  -          node.setUserData(  String.valueOf( fEntityManager.getEntityScanner().getLineNumber() ) ); // Save location String into node
  +          node.setUserData( "startLine", String.valueOf( locator.getLineNumber() ), null ); // Save location String into node
     } //startDocument 
      
   
  -   public void ignorableWhitespace(XMLString text) throws SAXException
  +   public void ignorableWhitespace(XMLString text, Augmentations augs) throws XNIException
       {
       if(! NotIncludeIgnorableWhiteSpaces )
  -       super.ignorableWhitespace( text);
  +       super.ignorableWhitespace( text, augs);
       else
          ;// Ignore ignorable white spaces
       }// ignorableWhitespace
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-cvs-help@xml.apache.org