jaxp/src/com/sun/org/apache/xml/internal/utils/TreeWalker.java
author joehw
Mon, 18 Feb 2013 11:33:35 -0800
changeset 16953 a44e04deb948
parent 12458 d601e4bba306
permissions -rw-r--r--
6657673: Issues with JAXP Reviewed-by: alanb, lancea, ahgross, mullan
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
6
7f561c08de6b Initial load
duke
parents:
diff changeset
     1
/*
7f561c08de6b Initial load
duke
parents:
diff changeset
     2
 * reserved comment block
7f561c08de6b Initial load
duke
parents:
diff changeset
     3
 * DO NOT REMOVE OR ALTER!
7f561c08de6b Initial load
duke
parents:
diff changeset
     4
 */
7f561c08de6b Initial load
duke
parents:
diff changeset
     5
/*
7f561c08de6b Initial load
duke
parents:
diff changeset
     6
 * Copyright 1999-2004 The Apache Software Foundation.
7f561c08de6b Initial load
duke
parents:
diff changeset
     7
 *
7f561c08de6b Initial load
duke
parents:
diff changeset
     8
 * Licensed under the Apache License, Version 2.0 (the "License");
7f561c08de6b Initial load
duke
parents:
diff changeset
     9
 * you may not use this file except in compliance with the License.
7f561c08de6b Initial load
duke
parents:
diff changeset
    10
 * You may obtain a copy of the License at
7f561c08de6b Initial load
duke
parents:
diff changeset
    11
 *
7f561c08de6b Initial load
duke
parents:
diff changeset
    12
 *     http://www.apache.org/licenses/LICENSE-2.0
7f561c08de6b Initial load
duke
parents:
diff changeset
    13
 *
7f561c08de6b Initial load
duke
parents:
diff changeset
    14
 * Unless required by applicable law or agreed to in writing, software
7f561c08de6b Initial load
duke
parents:
diff changeset
    15
 * distributed under the License is distributed on an "AS IS" BASIS,
7f561c08de6b Initial load
duke
parents:
diff changeset
    16
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
7f561c08de6b Initial load
duke
parents:
diff changeset
    17
 * See the License for the specific language governing permissions and
7f561c08de6b Initial load
duke
parents:
diff changeset
    18
 * limitations under the License.
7f561c08de6b Initial load
duke
parents:
diff changeset
    19
 */
7f561c08de6b Initial load
duke
parents:
diff changeset
    20
/*
7f561c08de6b Initial load
duke
parents:
diff changeset
    21
 * $Id: TreeWalker.java,v 1.2.4.1 2005/09/15 08:15:59 suresh_emailid Exp $
7f561c08de6b Initial load
duke
parents:
diff changeset
    22
 */
7f561c08de6b Initial load
duke
parents:
diff changeset
    23
package com.sun.org.apache.xml.internal.utils;
7f561c08de6b Initial load
duke
parents:
diff changeset
    24
16953
a44e04deb948 6657673: Issues with JAXP
joehw
parents: 12458
diff changeset
    25
import com.sun.org.apache.xalan.internal.utils.SecuritySupport;
6
7f561c08de6b Initial load
duke
parents:
diff changeset
    26
import java.io.File;
7f561c08de6b Initial load
duke
parents:
diff changeset
    27
7f561c08de6b Initial load
duke
parents:
diff changeset
    28
import org.w3c.dom.Comment;
7f561c08de6b Initial load
duke
parents:
diff changeset
    29
import org.w3c.dom.Element;
7f561c08de6b Initial load
duke
parents:
diff changeset
    30
import org.w3c.dom.EntityReference;
7f561c08de6b Initial load
duke
parents:
diff changeset
    31
import org.w3c.dom.NamedNodeMap;
7f561c08de6b Initial load
duke
parents:
diff changeset
    32
import org.w3c.dom.Node;
7f561c08de6b Initial load
duke
parents:
diff changeset
    33
import org.w3c.dom.ProcessingInstruction;
7f561c08de6b Initial load
duke
parents:
diff changeset
    34
import org.w3c.dom.Text;
7f561c08de6b Initial load
duke
parents:
diff changeset
    35
7f561c08de6b Initial load
duke
parents:
diff changeset
    36
import org.xml.sax.ContentHandler;
7f561c08de6b Initial load
duke
parents:
diff changeset
    37
import org.xml.sax.Locator;
7f561c08de6b Initial load
duke
parents:
diff changeset
    38
import org.xml.sax.ext.LexicalHandler;
7f561c08de6b Initial load
duke
parents:
diff changeset
    39
import org.xml.sax.helpers.LocatorImpl;
7f561c08de6b Initial load
duke
parents:
diff changeset
    40
7f561c08de6b Initial load
duke
parents:
diff changeset
    41
/**
7f561c08de6b Initial load
duke
parents:
diff changeset
    42
 * This class does a pre-order walk of the DOM tree, calling a ContentHandler
7f561c08de6b Initial load
duke
parents:
diff changeset
    43
 * interface as it goes.
7f561c08de6b Initial load
duke
parents:
diff changeset
    44
 * @xsl.usage advanced
7f561c08de6b Initial load
duke
parents:
diff changeset
    45
 */
7f561c08de6b Initial load
duke
parents:
diff changeset
    46
7f561c08de6b Initial load
duke
parents:
diff changeset
    47
public class TreeWalker
7f561c08de6b Initial load
duke
parents:
diff changeset
    48
{
7f561c08de6b Initial load
duke
parents:
diff changeset
    49
7f561c08de6b Initial load
duke
parents:
diff changeset
    50
  /** Local reference to a ContentHandler          */
7f561c08de6b Initial load
duke
parents:
diff changeset
    51
  private ContentHandler m_contentHandler = null;
7f561c08de6b Initial load
duke
parents:
diff changeset
    52
7f561c08de6b Initial load
duke
parents:
diff changeset
    53
  // ARGHH!!  JAXP Uses Xerces without setting the namespace processing to ON!
7f561c08de6b Initial load
duke
parents:
diff changeset
    54
  // DOM2Helper m_dh = new DOM2Helper();
7f561c08de6b Initial load
duke
parents:
diff changeset
    55
7f561c08de6b Initial load
duke
parents:
diff changeset
    56
  /** DomHelper for this TreeWalker          */
7f561c08de6b Initial load
duke
parents:
diff changeset
    57
  protected DOMHelper m_dh;
7f561c08de6b Initial load
duke
parents:
diff changeset
    58
7f561c08de6b Initial load
duke
parents:
diff changeset
    59
        /** Locator object for this TreeWalker          */
7f561c08de6b Initial load
duke
parents:
diff changeset
    60
        private LocatorImpl m_locator = new LocatorImpl();
7f561c08de6b Initial load
duke
parents:
diff changeset
    61
7f561c08de6b Initial load
duke
parents:
diff changeset
    62
  /**
7f561c08de6b Initial load
duke
parents:
diff changeset
    63
   * Get the ContentHandler used for the tree walk.
7f561c08de6b Initial load
duke
parents:
diff changeset
    64
   *
7f561c08de6b Initial load
duke
parents:
diff changeset
    65
   * @return the ContentHandler used for the tree walk
7f561c08de6b Initial load
duke
parents:
diff changeset
    66
   */
7f561c08de6b Initial load
duke
parents:
diff changeset
    67
  public ContentHandler getContentHandler()
7f561c08de6b Initial load
duke
parents:
diff changeset
    68
  {
7f561c08de6b Initial load
duke
parents:
diff changeset
    69
    return m_contentHandler;
7f561c08de6b Initial load
duke
parents:
diff changeset
    70
  }
7f561c08de6b Initial load
duke
parents:
diff changeset
    71
7f561c08de6b Initial load
duke
parents:
diff changeset
    72
  /**
7f561c08de6b Initial load
duke
parents:
diff changeset
    73
   * Get the ContentHandler used for the tree walk.
7f561c08de6b Initial load
duke
parents:
diff changeset
    74
   *
7f561c08de6b Initial load
duke
parents:
diff changeset
    75
   * @return the ContentHandler used for the tree walk
7f561c08de6b Initial load
duke
parents:
diff changeset
    76
   */
7f561c08de6b Initial load
duke
parents:
diff changeset
    77
  public void setContentHandler(ContentHandler ch)
7f561c08de6b Initial load
duke
parents:
diff changeset
    78
  {
7f561c08de6b Initial load
duke
parents:
diff changeset
    79
    m_contentHandler = ch;
7f561c08de6b Initial load
duke
parents:
diff changeset
    80
  }
7f561c08de6b Initial load
duke
parents:
diff changeset
    81
7f561c08de6b Initial load
duke
parents:
diff changeset
    82
        /**
7f561c08de6b Initial load
duke
parents:
diff changeset
    83
   * Constructor.
7f561c08de6b Initial load
duke
parents:
diff changeset
    84
   * @param   contentHandler The implemention of the
7f561c08de6b Initial load
duke
parents:
diff changeset
    85
   * @param   systemId System identifier for the document.
7f561c08de6b Initial load
duke
parents:
diff changeset
    86
   * contentHandler operation (toXMLString, digest, ...)
7f561c08de6b Initial load
duke
parents:
diff changeset
    87
   */
7f561c08de6b Initial load
duke
parents:
diff changeset
    88
  public TreeWalker(ContentHandler contentHandler, DOMHelper dh, String systemId)
7f561c08de6b Initial load
duke
parents:
diff changeset
    89
  {
7f561c08de6b Initial load
duke
parents:
diff changeset
    90
    this.m_contentHandler = contentHandler;
7f561c08de6b Initial load
duke
parents:
diff changeset
    91
    m_contentHandler.setDocumentLocator(m_locator);
7f561c08de6b Initial load
duke
parents:
diff changeset
    92
    if (systemId != null)
7f561c08de6b Initial load
duke
parents:
diff changeset
    93
        m_locator.setSystemId(systemId);
7f561c08de6b Initial load
duke
parents:
diff changeset
    94
    else {
7f561c08de6b Initial load
duke
parents:
diff changeset
    95
        try {
7f561c08de6b Initial load
duke
parents:
diff changeset
    96
          // Bug see Bugzilla  26741
16953
a44e04deb948 6657673: Issues with JAXP
joehw
parents: 12458
diff changeset
    97
          m_locator.setSystemId(SecuritySupport.getSystemProperty("user.dir") + File.separator + "dummy.xsl");
6
7f561c08de6b Initial load
duke
parents:
diff changeset
    98
         }
7f561c08de6b Initial load
duke
parents:
diff changeset
    99
         catch (SecurityException se) {// user.dir not accessible from applet
7f561c08de6b Initial load
duke
parents:
diff changeset
   100
         }
7f561c08de6b Initial load
duke
parents:
diff changeset
   101
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   102
    m_dh = dh;
7f561c08de6b Initial load
duke
parents:
diff changeset
   103
  }
7f561c08de6b Initial load
duke
parents:
diff changeset
   104
7f561c08de6b Initial load
duke
parents:
diff changeset
   105
  /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   106
   * Constructor.
7f561c08de6b Initial load
duke
parents:
diff changeset
   107
   * @param   contentHandler The implemention of the
7f561c08de6b Initial load
duke
parents:
diff changeset
   108
   * contentHandler operation (toXMLString, digest, ...)
7f561c08de6b Initial load
duke
parents:
diff changeset
   109
   */
7f561c08de6b Initial load
duke
parents:
diff changeset
   110
  public TreeWalker(ContentHandler contentHandler, DOMHelper dh)
7f561c08de6b Initial load
duke
parents:
diff changeset
   111
  {
7f561c08de6b Initial load
duke
parents:
diff changeset
   112
    this.m_contentHandler = contentHandler;
7f561c08de6b Initial load
duke
parents:
diff changeset
   113
    m_contentHandler.setDocumentLocator(m_locator);
7f561c08de6b Initial load
duke
parents:
diff changeset
   114
    try {
7f561c08de6b Initial load
duke
parents:
diff changeset
   115
       // Bug see Bugzilla  26741
16953
a44e04deb948 6657673: Issues with JAXP
joehw
parents: 12458
diff changeset
   116
      m_locator.setSystemId(SecuritySupport.getSystemProperty("user.dir") + File.separator + "dummy.xsl");
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   117
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   118
    catch (SecurityException se){// user.dir not accessible from applet
7f561c08de6b Initial load
duke
parents:
diff changeset
   119
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   120
    m_dh = dh;
7f561c08de6b Initial load
duke
parents:
diff changeset
   121
  }
7f561c08de6b Initial load
duke
parents:
diff changeset
   122
7f561c08de6b Initial load
duke
parents:
diff changeset
   123
  /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   124
   * Constructor.
7f561c08de6b Initial load
duke
parents:
diff changeset
   125
   * @param   contentHandler The implemention of the
7f561c08de6b Initial load
duke
parents:
diff changeset
   126
   * contentHandler operation (toXMLString, digest, ...)
7f561c08de6b Initial load
duke
parents:
diff changeset
   127
   */
7f561c08de6b Initial load
duke
parents:
diff changeset
   128
  public TreeWalker(ContentHandler contentHandler)
7f561c08de6b Initial load
duke
parents:
diff changeset
   129
  {
7f561c08de6b Initial load
duke
parents:
diff changeset
   130
    this.m_contentHandler = contentHandler;
7f561c08de6b Initial load
duke
parents:
diff changeset
   131
                if (m_contentHandler != null)
7f561c08de6b Initial load
duke
parents:
diff changeset
   132
                        m_contentHandler.setDocumentLocator(m_locator);
7f561c08de6b Initial load
duke
parents:
diff changeset
   133
                try {
7f561c08de6b Initial load
duke
parents:
diff changeset
   134
                   // Bug see Bugzilla  26741
16953
a44e04deb948 6657673: Issues with JAXP
joehw
parents: 12458
diff changeset
   135
                  m_locator.setSystemId(SecuritySupport.getSystemProperty("user.dir") + File.separator + "dummy.xsl");
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   136
                }
7f561c08de6b Initial load
duke
parents:
diff changeset
   137
                catch (SecurityException se){// user.dir not accessible from applet
7f561c08de6b Initial load
duke
parents:
diff changeset
   138
7f561c08de6b Initial load
duke
parents:
diff changeset
   139
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   140
    m_dh = new DOM2Helper();
7f561c08de6b Initial load
duke
parents:
diff changeset
   141
  }
7f561c08de6b Initial load
duke
parents:
diff changeset
   142
7f561c08de6b Initial load
duke
parents:
diff changeset
   143
  /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   144
   * Perform a pre-order traversal non-recursive style.
7f561c08de6b Initial load
duke
parents:
diff changeset
   145
   *
7f561c08de6b Initial load
duke
parents:
diff changeset
   146
   * Note that TreeWalker assumes that the subtree is intended to represent
7f561c08de6b Initial load
duke
parents:
diff changeset
   147
   * a complete (though not necessarily well-formed) document and, during a
7f561c08de6b Initial load
duke
parents:
diff changeset
   148
   * traversal, startDocument and endDocument will always be issued to the
7f561c08de6b Initial load
duke
parents:
diff changeset
   149
   * SAX listener.
7f561c08de6b Initial load
duke
parents:
diff changeset
   150
   *
7f561c08de6b Initial load
duke
parents:
diff changeset
   151
   * @param pos Node in the tree where to start traversal
7f561c08de6b Initial load
duke
parents:
diff changeset
   152
   *
7f561c08de6b Initial load
duke
parents:
diff changeset
   153
   * @throws TransformerException
7f561c08de6b Initial load
duke
parents:
diff changeset
   154
   */
7f561c08de6b Initial load
duke
parents:
diff changeset
   155
  public void traverse(Node pos) throws org.xml.sax.SAXException
7f561c08de6b Initial load
duke
parents:
diff changeset
   156
  {
7f561c08de6b Initial load
duke
parents:
diff changeset
   157
        this.m_contentHandler.startDocument();
7f561c08de6b Initial load
duke
parents:
diff changeset
   158
12458
d601e4bba306 7160380: Sync JDK8 with JAXP 1.4.5
joehw
parents: 12457
diff changeset
   159
        traverseFragment(pos);
d601e4bba306 7160380: Sync JDK8 with JAXP 1.4.5
joehw
parents: 12457
diff changeset
   160
d601e4bba306 7160380: Sync JDK8 with JAXP 1.4.5
joehw
parents: 12457
diff changeset
   161
        this.m_contentHandler.endDocument();
d601e4bba306 7160380: Sync JDK8 with JAXP 1.4.5
joehw
parents: 12457
diff changeset
   162
  }
d601e4bba306 7160380: Sync JDK8 with JAXP 1.4.5
joehw
parents: 12457
diff changeset
   163
d601e4bba306 7160380: Sync JDK8 with JAXP 1.4.5
joehw
parents: 12457
diff changeset
   164
  /**
d601e4bba306 7160380: Sync JDK8 with JAXP 1.4.5
joehw
parents: 12457
diff changeset
   165
   * Perform a pre-order traversal non-recursive style.
d601e4bba306 7160380: Sync JDK8 with JAXP 1.4.5
joehw
parents: 12457
diff changeset
   166
   *
d601e4bba306 7160380: Sync JDK8 with JAXP 1.4.5
joehw
parents: 12457
diff changeset
   167
   * In contrast to the traverse() method this method will not issue
d601e4bba306 7160380: Sync JDK8 with JAXP 1.4.5
joehw
parents: 12457
diff changeset
   168
   * startDocument() and endDocument() events to the SAX listener.
d601e4bba306 7160380: Sync JDK8 with JAXP 1.4.5
joehw
parents: 12457
diff changeset
   169
   *
d601e4bba306 7160380: Sync JDK8 with JAXP 1.4.5
joehw
parents: 12457
diff changeset
   170
   * @param pos Node in the tree where to start traversal
d601e4bba306 7160380: Sync JDK8 with JAXP 1.4.5
joehw
parents: 12457
diff changeset
   171
   *
d601e4bba306 7160380: Sync JDK8 with JAXP 1.4.5
joehw
parents: 12457
diff changeset
   172
   * @throws TransformerException
d601e4bba306 7160380: Sync JDK8 with JAXP 1.4.5
joehw
parents: 12457
diff changeset
   173
   */
d601e4bba306 7160380: Sync JDK8 with JAXP 1.4.5
joehw
parents: 12457
diff changeset
   174
  public void traverseFragment(Node pos) throws org.xml.sax.SAXException
d601e4bba306 7160380: Sync JDK8 with JAXP 1.4.5
joehw
parents: 12457
diff changeset
   175
  {
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   176
    Node top = pos;
7f561c08de6b Initial load
duke
parents:
diff changeset
   177
7f561c08de6b Initial load
duke
parents:
diff changeset
   178
    while (null != pos)
7f561c08de6b Initial load
duke
parents:
diff changeset
   179
    {
7f561c08de6b Initial load
duke
parents:
diff changeset
   180
      startNode(pos);
7f561c08de6b Initial load
duke
parents:
diff changeset
   181
7f561c08de6b Initial load
duke
parents:
diff changeset
   182
      Node nextNode = pos.getFirstChild();
7f561c08de6b Initial load
duke
parents:
diff changeset
   183
7f561c08de6b Initial load
duke
parents:
diff changeset
   184
      while (null == nextNode)
7f561c08de6b Initial load
duke
parents:
diff changeset
   185
      {
7f561c08de6b Initial load
duke
parents:
diff changeset
   186
        endNode(pos);
7f561c08de6b Initial load
duke
parents:
diff changeset
   187
7f561c08de6b Initial load
duke
parents:
diff changeset
   188
        if (top.equals(pos))
7f561c08de6b Initial load
duke
parents:
diff changeset
   189
          break;
7f561c08de6b Initial load
duke
parents:
diff changeset
   190
7f561c08de6b Initial load
duke
parents:
diff changeset
   191
        nextNode = pos.getNextSibling();
7f561c08de6b Initial load
duke
parents:
diff changeset
   192
7f561c08de6b Initial load
duke
parents:
diff changeset
   193
        if (null == nextNode)
7f561c08de6b Initial load
duke
parents:
diff changeset
   194
        {
7f561c08de6b Initial load
duke
parents:
diff changeset
   195
          pos = pos.getParentNode();
7f561c08de6b Initial load
duke
parents:
diff changeset
   196
7f561c08de6b Initial load
duke
parents:
diff changeset
   197
          if ((null == pos) || (top.equals(pos)))
7f561c08de6b Initial load
duke
parents:
diff changeset
   198
          {
7f561c08de6b Initial load
duke
parents:
diff changeset
   199
            if (null != pos)
7f561c08de6b Initial load
duke
parents:
diff changeset
   200
              endNode(pos);
7f561c08de6b Initial load
duke
parents:
diff changeset
   201
7f561c08de6b Initial load
duke
parents:
diff changeset
   202
            nextNode = null;
7f561c08de6b Initial load
duke
parents:
diff changeset
   203
7f561c08de6b Initial load
duke
parents:
diff changeset
   204
            break;
7f561c08de6b Initial load
duke
parents:
diff changeset
   205
          }
7f561c08de6b Initial load
duke
parents:
diff changeset
   206
        }
7f561c08de6b Initial load
duke
parents:
diff changeset
   207
      }
7f561c08de6b Initial load
duke
parents:
diff changeset
   208
7f561c08de6b Initial load
duke
parents:
diff changeset
   209
      pos = nextNode;
7f561c08de6b Initial load
duke
parents:
diff changeset
   210
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   211
  }
7f561c08de6b Initial load
duke
parents:
diff changeset
   212
7f561c08de6b Initial load
duke
parents:
diff changeset
   213
  /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   214
   * Perform a pre-order traversal non-recursive style.
7f561c08de6b Initial load
duke
parents:
diff changeset
   215
7f561c08de6b Initial load
duke
parents:
diff changeset
   216
   * Note that TreeWalker assumes that the subtree is intended to represent
7f561c08de6b Initial load
duke
parents:
diff changeset
   217
   * a complete (though not necessarily well-formed) document and, during a
7f561c08de6b Initial load
duke
parents:
diff changeset
   218
   * traversal, startDocument and endDocument will always be issued to the
7f561c08de6b Initial load
duke
parents:
diff changeset
   219
   * SAX listener.
7f561c08de6b Initial load
duke
parents:
diff changeset
   220
   *
7f561c08de6b Initial load
duke
parents:
diff changeset
   221
   * @param pos Node in the tree where to start traversal
7f561c08de6b Initial load
duke
parents:
diff changeset
   222
   * @param top Node in the tree where to end traversal
7f561c08de6b Initial load
duke
parents:
diff changeset
   223
   *
7f561c08de6b Initial load
duke
parents:
diff changeset
   224
   * @throws TransformerException
7f561c08de6b Initial load
duke
parents:
diff changeset
   225
   */
7f561c08de6b Initial load
duke
parents:
diff changeset
   226
  public void traverse(Node pos, Node top) throws org.xml.sax.SAXException
7f561c08de6b Initial load
duke
parents:
diff changeset
   227
  {
7f561c08de6b Initial load
duke
parents:
diff changeset
   228
7f561c08de6b Initial load
duke
parents:
diff changeset
   229
        this.m_contentHandler.startDocument();
7f561c08de6b Initial load
duke
parents:
diff changeset
   230
7f561c08de6b Initial load
duke
parents:
diff changeset
   231
    while (null != pos)
7f561c08de6b Initial load
duke
parents:
diff changeset
   232
    {
7f561c08de6b Initial load
duke
parents:
diff changeset
   233
      startNode(pos);
7f561c08de6b Initial load
duke
parents:
diff changeset
   234
7f561c08de6b Initial load
duke
parents:
diff changeset
   235
      Node nextNode = pos.getFirstChild();
7f561c08de6b Initial load
duke
parents:
diff changeset
   236
7f561c08de6b Initial load
duke
parents:
diff changeset
   237
      while (null == nextNode)
7f561c08de6b Initial load
duke
parents:
diff changeset
   238
      {
7f561c08de6b Initial load
duke
parents:
diff changeset
   239
        endNode(pos);
7f561c08de6b Initial load
duke
parents:
diff changeset
   240
7f561c08de6b Initial load
duke
parents:
diff changeset
   241
        if ((null != top) && top.equals(pos))
7f561c08de6b Initial load
duke
parents:
diff changeset
   242
          break;
7f561c08de6b Initial load
duke
parents:
diff changeset
   243
7f561c08de6b Initial load
duke
parents:
diff changeset
   244
        nextNode = pos.getNextSibling();
7f561c08de6b Initial load
duke
parents:
diff changeset
   245
7f561c08de6b Initial load
duke
parents:
diff changeset
   246
        if (null == nextNode)
7f561c08de6b Initial load
duke
parents:
diff changeset
   247
        {
7f561c08de6b Initial load
duke
parents:
diff changeset
   248
          pos = pos.getParentNode();
7f561c08de6b Initial load
duke
parents:
diff changeset
   249
7f561c08de6b Initial load
duke
parents:
diff changeset
   250
          if ((null == pos) || ((null != top) && top.equals(pos)))
7f561c08de6b Initial load
duke
parents:
diff changeset
   251
          {
7f561c08de6b Initial load
duke
parents:
diff changeset
   252
            nextNode = null;
7f561c08de6b Initial load
duke
parents:
diff changeset
   253
7f561c08de6b Initial load
duke
parents:
diff changeset
   254
            break;
7f561c08de6b Initial load
duke
parents:
diff changeset
   255
          }
7f561c08de6b Initial load
duke
parents:
diff changeset
   256
        }
7f561c08de6b Initial load
duke
parents:
diff changeset
   257
      }
7f561c08de6b Initial load
duke
parents:
diff changeset
   258
7f561c08de6b Initial load
duke
parents:
diff changeset
   259
      pos = nextNode;
7f561c08de6b Initial load
duke
parents:
diff changeset
   260
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   261
    this.m_contentHandler.endDocument();
7f561c08de6b Initial load
duke
parents:
diff changeset
   262
  }
7f561c08de6b Initial load
duke
parents:
diff changeset
   263
7f561c08de6b Initial load
duke
parents:
diff changeset
   264
  /** Flag indicating whether following text to be processed is raw text          */
7f561c08de6b Initial load
duke
parents:
diff changeset
   265
  boolean nextIsRaw = false;
7f561c08de6b Initial load
duke
parents:
diff changeset
   266
7f561c08de6b Initial load
duke
parents:
diff changeset
   267
  /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   268
   * Optimized dispatch of characters.
7f561c08de6b Initial load
duke
parents:
diff changeset
   269
   */
7f561c08de6b Initial load
duke
parents:
diff changeset
   270
  private final void dispatachChars(Node node)
7f561c08de6b Initial load
duke
parents:
diff changeset
   271
     throws org.xml.sax.SAXException
7f561c08de6b Initial load
duke
parents:
diff changeset
   272
  {
7f561c08de6b Initial load
duke
parents:
diff changeset
   273
    if(m_contentHandler instanceof com.sun.org.apache.xml.internal.dtm.ref.dom2dtm.DOM2DTM.CharacterNodeHandler)
7f561c08de6b Initial load
duke
parents:
diff changeset
   274
    {
7f561c08de6b Initial load
duke
parents:
diff changeset
   275
      ((com.sun.org.apache.xml.internal.dtm.ref.dom2dtm.DOM2DTM.CharacterNodeHandler)m_contentHandler).characters(node);
7f561c08de6b Initial load
duke
parents:
diff changeset
   276
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   277
    else
7f561c08de6b Initial load
duke
parents:
diff changeset
   278
    {
7f561c08de6b Initial load
duke
parents:
diff changeset
   279
      String data = ((Text) node).getData();
7f561c08de6b Initial load
duke
parents:
diff changeset
   280
      this.m_contentHandler.characters(data.toCharArray(), 0, data.length());
7f561c08de6b Initial load
duke
parents:
diff changeset
   281
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   282
  }
7f561c08de6b Initial load
duke
parents:
diff changeset
   283
7f561c08de6b Initial load
duke
parents:
diff changeset
   284
  /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   285
   * Start processing given node
7f561c08de6b Initial load
duke
parents:
diff changeset
   286
   *
7f561c08de6b Initial load
duke
parents:
diff changeset
   287
   *
7f561c08de6b Initial load
duke
parents:
diff changeset
   288
   * @param node Node to process
7f561c08de6b Initial load
duke
parents:
diff changeset
   289
   *
7f561c08de6b Initial load
duke
parents:
diff changeset
   290
   * @throws org.xml.sax.SAXException
7f561c08de6b Initial load
duke
parents:
diff changeset
   291
   */
7f561c08de6b Initial load
duke
parents:
diff changeset
   292
  protected void startNode(Node node) throws org.xml.sax.SAXException
7f561c08de6b Initial load
duke
parents:
diff changeset
   293
  {
7f561c08de6b Initial load
duke
parents:
diff changeset
   294
7f561c08de6b Initial load
duke
parents:
diff changeset
   295
    if (m_contentHandler instanceof NodeConsumer)
7f561c08de6b Initial load
duke
parents:
diff changeset
   296
    {
7f561c08de6b Initial load
duke
parents:
diff changeset
   297
      ((NodeConsumer) m_contentHandler).setOriginatingNode(node);
7f561c08de6b Initial load
duke
parents:
diff changeset
   298
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   299
7f561c08de6b Initial load
duke
parents:
diff changeset
   300
                if (node instanceof Locator)
7f561c08de6b Initial load
duke
parents:
diff changeset
   301
                {
7f561c08de6b Initial load
duke
parents:
diff changeset
   302
                        Locator loc = (Locator)node;
7f561c08de6b Initial load
duke
parents:
diff changeset
   303
                        m_locator.setColumnNumber(loc.getColumnNumber());
7f561c08de6b Initial load
duke
parents:
diff changeset
   304
                        m_locator.setLineNumber(loc.getLineNumber());
7f561c08de6b Initial load
duke
parents:
diff changeset
   305
                        m_locator.setPublicId(loc.getPublicId());
7f561c08de6b Initial load
duke
parents:
diff changeset
   306
                        m_locator.setSystemId(loc.getSystemId());
7f561c08de6b Initial load
duke
parents:
diff changeset
   307
                }
7f561c08de6b Initial load
duke
parents:
diff changeset
   308
                else
7f561c08de6b Initial load
duke
parents:
diff changeset
   309
                {
7f561c08de6b Initial load
duke
parents:
diff changeset
   310
                        m_locator.setColumnNumber(0);
7f561c08de6b Initial load
duke
parents:
diff changeset
   311
      m_locator.setLineNumber(0);
7f561c08de6b Initial load
duke
parents:
diff changeset
   312
                }
7f561c08de6b Initial load
duke
parents:
diff changeset
   313
7f561c08de6b Initial load
duke
parents:
diff changeset
   314
    switch (node.getNodeType())
7f561c08de6b Initial load
duke
parents:
diff changeset
   315
    {
7f561c08de6b Initial load
duke
parents:
diff changeset
   316
    case Node.COMMENT_NODE :
7f561c08de6b Initial load
duke
parents:
diff changeset
   317
    {
7f561c08de6b Initial load
duke
parents:
diff changeset
   318
      String data = ((Comment) node).getData();
7f561c08de6b Initial load
duke
parents:
diff changeset
   319
7f561c08de6b Initial load
duke
parents:
diff changeset
   320
      if (m_contentHandler instanceof LexicalHandler)
7f561c08de6b Initial load
duke
parents:
diff changeset
   321
      {
7f561c08de6b Initial load
duke
parents:
diff changeset
   322
        LexicalHandler lh = ((LexicalHandler) this.m_contentHandler);
7f561c08de6b Initial load
duke
parents:
diff changeset
   323
7f561c08de6b Initial load
duke
parents:
diff changeset
   324
        lh.comment(data.toCharArray(), 0, data.length());
7f561c08de6b Initial load
duke
parents:
diff changeset
   325
      }
7f561c08de6b Initial load
duke
parents:
diff changeset
   326
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   327
    break;
7f561c08de6b Initial load
duke
parents:
diff changeset
   328
    case Node.DOCUMENT_FRAGMENT_NODE :
7f561c08de6b Initial load
duke
parents:
diff changeset
   329
7f561c08de6b Initial load
duke
parents:
diff changeset
   330
      // ??;
7f561c08de6b Initial load
duke
parents:
diff changeset
   331
      break;
7f561c08de6b Initial load
duke
parents:
diff changeset
   332
    case Node.DOCUMENT_NODE :
7f561c08de6b Initial load
duke
parents:
diff changeset
   333
7f561c08de6b Initial load
duke
parents:
diff changeset
   334
      break;
7f561c08de6b Initial load
duke
parents:
diff changeset
   335
    case Node.ELEMENT_NODE :
7f561c08de6b Initial load
duke
parents:
diff changeset
   336
      NamedNodeMap atts = ((Element) node).getAttributes();
7f561c08de6b Initial load
duke
parents:
diff changeset
   337
      int nAttrs = atts.getLength();
7f561c08de6b Initial load
duke
parents:
diff changeset
   338
      // System.out.println("TreeWalker#startNode: "+node.getNodeName());
7f561c08de6b Initial load
duke
parents:
diff changeset
   339
7f561c08de6b Initial load
duke
parents:
diff changeset
   340
      for (int i = 0; i < nAttrs; i++)
7f561c08de6b Initial load
duke
parents:
diff changeset
   341
      {
7f561c08de6b Initial load
duke
parents:
diff changeset
   342
        Node attr = atts.item(i);
7f561c08de6b Initial load
duke
parents:
diff changeset
   343
        String attrName = attr.getNodeName();
7f561c08de6b Initial load
duke
parents:
diff changeset
   344
7f561c08de6b Initial load
duke
parents:
diff changeset
   345
        // System.out.println("TreeWalker#startNode: attr["+i+"] = "+attrName+", "+attr.getNodeValue());
7f561c08de6b Initial load
duke
parents:
diff changeset
   346
        if (attrName.equals("xmlns") || attrName.startsWith("xmlns:"))
7f561c08de6b Initial load
duke
parents:
diff changeset
   347
        {
7f561c08de6b Initial load
duke
parents:
diff changeset
   348
          // System.out.println("TreeWalker#startNode: attr["+i+"] = "+attrName+", "+attr.getNodeValue());
7f561c08de6b Initial load
duke
parents:
diff changeset
   349
          int index;
7f561c08de6b Initial load
duke
parents:
diff changeset
   350
          // Use "" instead of null, as Xerces likes "" for the
7f561c08de6b Initial load
duke
parents:
diff changeset
   351
          // name of the default namespace.  Fix attributed
7f561c08de6b Initial load
duke
parents:
diff changeset
   352
          // to "Steven Murray" <smurray@ebt.com>.
7f561c08de6b Initial load
duke
parents:
diff changeset
   353
          String prefix = (index = attrName.indexOf(":")) < 0
7f561c08de6b Initial load
duke
parents:
diff changeset
   354
                          ? "" : attrName.substring(index + 1);
7f561c08de6b Initial load
duke
parents:
diff changeset
   355
7f561c08de6b Initial load
duke
parents:
diff changeset
   356
          this.m_contentHandler.startPrefixMapping(prefix,
7f561c08de6b Initial load
duke
parents:
diff changeset
   357
                                                   attr.getNodeValue());
7f561c08de6b Initial load
duke
parents:
diff changeset
   358
        }
7f561c08de6b Initial load
duke
parents:
diff changeset
   359
7f561c08de6b Initial load
duke
parents:
diff changeset
   360
      }
7f561c08de6b Initial load
duke
parents:
diff changeset
   361
7f561c08de6b Initial load
duke
parents:
diff changeset
   362
      // System.out.println("m_dh.getNamespaceOfNode(node): "+m_dh.getNamespaceOfNode(node));
7f561c08de6b Initial load
duke
parents:
diff changeset
   363
      // System.out.println("m_dh.getLocalNameOfNode(node): "+m_dh.getLocalNameOfNode(node));
7f561c08de6b Initial load
duke
parents:
diff changeset
   364
      String ns = m_dh.getNamespaceOfNode(node);
7f561c08de6b Initial load
duke
parents:
diff changeset
   365
      if(null == ns)
7f561c08de6b Initial load
duke
parents:
diff changeset
   366
        ns = "";
7f561c08de6b Initial load
duke
parents:
diff changeset
   367
      this.m_contentHandler.startElement(ns,
7f561c08de6b Initial load
duke
parents:
diff changeset
   368
                                         m_dh.getLocalNameOfNode(node),
7f561c08de6b Initial load
duke
parents:
diff changeset
   369
                                         node.getNodeName(),
7f561c08de6b Initial load
duke
parents:
diff changeset
   370
                                         new AttList(atts, m_dh));
7f561c08de6b Initial load
duke
parents:
diff changeset
   371
      break;
7f561c08de6b Initial load
duke
parents:
diff changeset
   372
    case Node.PROCESSING_INSTRUCTION_NODE :
7f561c08de6b Initial load
duke
parents:
diff changeset
   373
    {
7f561c08de6b Initial load
duke
parents:
diff changeset
   374
      ProcessingInstruction pi = (ProcessingInstruction) node;
7f561c08de6b Initial load
duke
parents:
diff changeset
   375
      String name = pi.getNodeName();
7f561c08de6b Initial load
duke
parents:
diff changeset
   376
7f561c08de6b Initial load
duke
parents:
diff changeset
   377
      // String data = pi.getData();
7f561c08de6b Initial load
duke
parents:
diff changeset
   378
      if (name.equals("xslt-next-is-raw"))
7f561c08de6b Initial load
duke
parents:
diff changeset
   379
      {
7f561c08de6b Initial load
duke
parents:
diff changeset
   380
        nextIsRaw = true;
7f561c08de6b Initial load
duke
parents:
diff changeset
   381
      }
7f561c08de6b Initial load
duke
parents:
diff changeset
   382
      else
7f561c08de6b Initial load
duke
parents:
diff changeset
   383
      {
7f561c08de6b Initial load
duke
parents:
diff changeset
   384
        this.m_contentHandler.processingInstruction(pi.getNodeName(),
7f561c08de6b Initial load
duke
parents:
diff changeset
   385
                                                    pi.getData());
7f561c08de6b Initial load
duke
parents:
diff changeset
   386
      }
7f561c08de6b Initial load
duke
parents:
diff changeset
   387
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   388
    break;
7f561c08de6b Initial load
duke
parents:
diff changeset
   389
    case Node.CDATA_SECTION_NODE :
7f561c08de6b Initial load
duke
parents:
diff changeset
   390
    {
7f561c08de6b Initial load
duke
parents:
diff changeset
   391
      boolean isLexH = (m_contentHandler instanceof LexicalHandler);
7f561c08de6b Initial load
duke
parents:
diff changeset
   392
      LexicalHandler lh = isLexH
7f561c08de6b Initial load
duke
parents:
diff changeset
   393
                          ? ((LexicalHandler) this.m_contentHandler) : null;
7f561c08de6b Initial load
duke
parents:
diff changeset
   394
7f561c08de6b Initial load
duke
parents:
diff changeset
   395
      if (isLexH)
7f561c08de6b Initial load
duke
parents:
diff changeset
   396
      {
7f561c08de6b Initial load
duke
parents:
diff changeset
   397
        lh.startCDATA();
7f561c08de6b Initial load
duke
parents:
diff changeset
   398
      }
7f561c08de6b Initial load
duke
parents:
diff changeset
   399
7f561c08de6b Initial load
duke
parents:
diff changeset
   400
      dispatachChars(node);
7f561c08de6b Initial load
duke
parents:
diff changeset
   401
7f561c08de6b Initial load
duke
parents:
diff changeset
   402
      {
7f561c08de6b Initial load
duke
parents:
diff changeset
   403
        if (isLexH)
7f561c08de6b Initial load
duke
parents:
diff changeset
   404
        {
7f561c08de6b Initial load
duke
parents:
diff changeset
   405
          lh.endCDATA();
7f561c08de6b Initial load
duke
parents:
diff changeset
   406
        }
7f561c08de6b Initial load
duke
parents:
diff changeset
   407
      }
7f561c08de6b Initial load
duke
parents:
diff changeset
   408
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   409
    break;
7f561c08de6b Initial load
duke
parents:
diff changeset
   410
    case Node.TEXT_NODE :
7f561c08de6b Initial load
duke
parents:
diff changeset
   411
    {
7f561c08de6b Initial load
duke
parents:
diff changeset
   412
      //String data = ((Text) node).getData();
7f561c08de6b Initial load
duke
parents:
diff changeset
   413
7f561c08de6b Initial load
duke
parents:
diff changeset
   414
      if (nextIsRaw)
7f561c08de6b Initial load
duke
parents:
diff changeset
   415
      {
7f561c08de6b Initial load
duke
parents:
diff changeset
   416
        nextIsRaw = false;
7f561c08de6b Initial load
duke
parents:
diff changeset
   417
7f561c08de6b Initial load
duke
parents:
diff changeset
   418
        m_contentHandler.processingInstruction(javax.xml.transform.Result.PI_DISABLE_OUTPUT_ESCAPING, "");
7f561c08de6b Initial load
duke
parents:
diff changeset
   419
        dispatachChars(node);
7f561c08de6b Initial load
duke
parents:
diff changeset
   420
        m_contentHandler.processingInstruction(javax.xml.transform.Result.PI_ENABLE_OUTPUT_ESCAPING, "");
7f561c08de6b Initial load
duke
parents:
diff changeset
   421
      }
7f561c08de6b Initial load
duke
parents:
diff changeset
   422
      else
7f561c08de6b Initial load
duke
parents:
diff changeset
   423
      {
7f561c08de6b Initial load
duke
parents:
diff changeset
   424
        dispatachChars(node);
7f561c08de6b Initial load
duke
parents:
diff changeset
   425
      }
7f561c08de6b Initial load
duke
parents:
diff changeset
   426
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   427
    break;
7f561c08de6b Initial load
duke
parents:
diff changeset
   428
    case Node.ENTITY_REFERENCE_NODE :
7f561c08de6b Initial load
duke
parents:
diff changeset
   429
    {
7f561c08de6b Initial load
duke
parents:
diff changeset
   430
      EntityReference eref = (EntityReference) node;
7f561c08de6b Initial load
duke
parents:
diff changeset
   431
7f561c08de6b Initial load
duke
parents:
diff changeset
   432
      if (m_contentHandler instanceof LexicalHandler)
7f561c08de6b Initial load
duke
parents:
diff changeset
   433
      {
7f561c08de6b Initial load
duke
parents:
diff changeset
   434
        ((LexicalHandler) this.m_contentHandler).startEntity(
7f561c08de6b Initial load
duke
parents:
diff changeset
   435
          eref.getNodeName());
7f561c08de6b Initial load
duke
parents:
diff changeset
   436
      }
7f561c08de6b Initial load
duke
parents:
diff changeset
   437
      else
7f561c08de6b Initial load
duke
parents:
diff changeset
   438
      {
7f561c08de6b Initial load
duke
parents:
diff changeset
   439
7f561c08de6b Initial load
duke
parents:
diff changeset
   440
        // warning("Can not output entity to a pure SAX ContentHandler");
7f561c08de6b Initial load
duke
parents:
diff changeset
   441
      }
7f561c08de6b Initial load
duke
parents:
diff changeset
   442
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   443
    break;
7f561c08de6b Initial load
duke
parents:
diff changeset
   444
    default :
7f561c08de6b Initial load
duke
parents:
diff changeset
   445
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   446
  }
7f561c08de6b Initial load
duke
parents:
diff changeset
   447
7f561c08de6b Initial load
duke
parents:
diff changeset
   448
  /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   449
   * End processing of given node
7f561c08de6b Initial load
duke
parents:
diff changeset
   450
   *
7f561c08de6b Initial load
duke
parents:
diff changeset
   451
   *
7f561c08de6b Initial load
duke
parents:
diff changeset
   452
   * @param node Node we just finished processing
7f561c08de6b Initial load
duke
parents:
diff changeset
   453
   *
7f561c08de6b Initial load
duke
parents:
diff changeset
   454
   * @throws org.xml.sax.SAXException
7f561c08de6b Initial load
duke
parents:
diff changeset
   455
   */
7f561c08de6b Initial load
duke
parents:
diff changeset
   456
  protected void endNode(Node node) throws org.xml.sax.SAXException
7f561c08de6b Initial load
duke
parents:
diff changeset
   457
  {
7f561c08de6b Initial load
duke
parents:
diff changeset
   458
7f561c08de6b Initial load
duke
parents:
diff changeset
   459
    switch (node.getNodeType())
7f561c08de6b Initial load
duke
parents:
diff changeset
   460
    {
7f561c08de6b Initial load
duke
parents:
diff changeset
   461
    case Node.DOCUMENT_NODE :
7f561c08de6b Initial load
duke
parents:
diff changeset
   462
      break;
7f561c08de6b Initial load
duke
parents:
diff changeset
   463
7f561c08de6b Initial load
duke
parents:
diff changeset
   464
    case Node.ELEMENT_NODE :
7f561c08de6b Initial load
duke
parents:
diff changeset
   465
      String ns = m_dh.getNamespaceOfNode(node);
7f561c08de6b Initial load
duke
parents:
diff changeset
   466
      if(null == ns)
7f561c08de6b Initial load
duke
parents:
diff changeset
   467
        ns = "";
7f561c08de6b Initial load
duke
parents:
diff changeset
   468
      this.m_contentHandler.endElement(ns,
7f561c08de6b Initial load
duke
parents:
diff changeset
   469
                                         m_dh.getLocalNameOfNode(node),
7f561c08de6b Initial load
duke
parents:
diff changeset
   470
                                         node.getNodeName());
7f561c08de6b Initial load
duke
parents:
diff changeset
   471
7f561c08de6b Initial load
duke
parents:
diff changeset
   472
      NamedNodeMap atts = ((Element) node).getAttributes();
7f561c08de6b Initial load
duke
parents:
diff changeset
   473
      int nAttrs = atts.getLength();
7f561c08de6b Initial load
duke
parents:
diff changeset
   474
7f561c08de6b Initial load
duke
parents:
diff changeset
   475
      for (int i = 0; i < nAttrs; i++)
7f561c08de6b Initial load
duke
parents:
diff changeset
   476
      {
7f561c08de6b Initial load
duke
parents:
diff changeset
   477
        Node attr = atts.item(i);
7f561c08de6b Initial load
duke
parents:
diff changeset
   478
        String attrName = attr.getNodeName();
7f561c08de6b Initial load
duke
parents:
diff changeset
   479
7f561c08de6b Initial load
duke
parents:
diff changeset
   480
        if (attrName.equals("xmlns") || attrName.startsWith("xmlns:"))
7f561c08de6b Initial load
duke
parents:
diff changeset
   481
        {
7f561c08de6b Initial load
duke
parents:
diff changeset
   482
          int index;
7f561c08de6b Initial load
duke
parents:
diff changeset
   483
          // Use "" instead of null, as Xerces likes "" for the
7f561c08de6b Initial load
duke
parents:
diff changeset
   484
          // name of the default namespace.  Fix attributed
7f561c08de6b Initial load
duke
parents:
diff changeset
   485
          // to "Steven Murray" <smurray@ebt.com>.
7f561c08de6b Initial load
duke
parents:
diff changeset
   486
          String prefix = (index = attrName.indexOf(":")) < 0
7f561c08de6b Initial load
duke
parents:
diff changeset
   487
                          ? "" : attrName.substring(index + 1);
7f561c08de6b Initial load
duke
parents:
diff changeset
   488
7f561c08de6b Initial load
duke
parents:
diff changeset
   489
          this.m_contentHandler.endPrefixMapping(prefix);
7f561c08de6b Initial load
duke
parents:
diff changeset
   490
        }
7f561c08de6b Initial load
duke
parents:
diff changeset
   491
      }
7f561c08de6b Initial load
duke
parents:
diff changeset
   492
      break;
7f561c08de6b Initial load
duke
parents:
diff changeset
   493
    case Node.CDATA_SECTION_NODE :
7f561c08de6b Initial load
duke
parents:
diff changeset
   494
      break;
7f561c08de6b Initial load
duke
parents:
diff changeset
   495
    case Node.ENTITY_REFERENCE_NODE :
7f561c08de6b Initial load
duke
parents:
diff changeset
   496
    {
7f561c08de6b Initial load
duke
parents:
diff changeset
   497
      EntityReference eref = (EntityReference) node;
7f561c08de6b Initial load
duke
parents:
diff changeset
   498
7f561c08de6b Initial load
duke
parents:
diff changeset
   499
      if (m_contentHandler instanceof LexicalHandler)
7f561c08de6b Initial load
duke
parents:
diff changeset
   500
      {
7f561c08de6b Initial load
duke
parents:
diff changeset
   501
        LexicalHandler lh = ((LexicalHandler) this.m_contentHandler);
7f561c08de6b Initial load
duke
parents:
diff changeset
   502
7f561c08de6b Initial load
duke
parents:
diff changeset
   503
        lh.endEntity(eref.getNodeName());
7f561c08de6b Initial load
duke
parents:
diff changeset
   504
      }
7f561c08de6b Initial load
duke
parents:
diff changeset
   505
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   506
    break;
7f561c08de6b Initial load
duke
parents:
diff changeset
   507
    default :
7f561c08de6b Initial load
duke
parents:
diff changeset
   508
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   509
  }
7f561c08de6b Initial load
duke
parents:
diff changeset
   510
}  //TreeWalker