< prev index next >

src/java.xml/share/classes/com/sun/org/apache/xml/internal/serializer/dom3/DOM3TreeWalker.java

Print this page


   1 /*
   2  * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
   3  */
   4 /*
   5  * Licensed to the Apache Software Foundation (ASF) under one or more
   6  * contributor license agreements.  See the NOTICE file distributed with
   7  * this work for additional information regarding copyright ownership.
   8  * The ASF licenses this file to You under the Apache License, Version 2.0
   9  * (the "License"); you may not use this file except in compliance with
  10  * the License.  You may obtain a copy of the License at
  11  *
  12  *      http://www.apache.org/licenses/LICENSE-2.0
  13  *
  14  * Unless required by applicable law or agreed to in writing, software
  15  * distributed under the License is distributed on an "AS IS" BASIS,
  16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  17  * See the License for the specific language governing permissions and
  18  * limitations under the License.
  19  */
  20 
  21 package com.sun.org.apache.xml.internal.serializer.dom3;
  22 


 351 
 352                     if ((null == pos) || ((null != top) && top.equals(pos))) {
 353                         nextNode = null;
 354 
 355                         break;
 356                     }
 357                 }
 358             }
 359 
 360             pos = nextNode;
 361         }
 362         this.fSerializer.endDocument();
 363     }
 364 
 365     /**
 366      * Optimized dispatch of characters.
 367      */
 368     private final void dispatachChars(Node node)
 369         throws org.xml.sax.SAXException {
 370         if (fSerializer != null) {
 371             this.fSerializer.characters(node);
 372         } else {
 373             String data = ((Text) node).getData();
 374             this.fSerializer.characters(data.toCharArray(), 0, data.length());
 375         }
 376     }
 377 
 378     /**
 379      * Start processing given node
 380      *
 381      * @param node Node to process
 382      *
 383      * @throws org.xml.sax.SAXException
 384      */
 385     protected void startNode(Node node) throws org.xml.sax.SAXException {
 386         if (node instanceof Locator) {
 387             Locator loc = (Locator) node;
 388             fLocator.setColumnNumber(loc.getColumnNumber());
 389             fLocator.setLineNumber(loc.getLineNumber());
 390             fLocator.setPublicId(loc.getPublicId());
 391             fLocator.setSystemId(loc.getSystemId());
 392         } else {


1049 
1050                 // perform well-formedness and other checking only if
1051                 // entities = true
1052 
1053                 // well-formed=true
1054                 if ((fFeatures & WELLFORMED) != 0) {
1055                     isEntityReferneceWellFormed(node);
1056                 }
1057 
1058                 // check "unbound-prefix-in-entity-reference" [fatal]
1059                 // Raised if the configuration parameter "namespaces" is set to true
1060                 if ((fFeatures & NAMESPACES) != 0) {
1061                     checkUnboundPrefixInEntRef(node);
1062                 }
1063 
1064                 // The filter should not apply in this case, since the
1065                 // EntityReference is not being expanded.
1066                 // should we pass entity reference nodes to the filter???
1067             }
1068 
1069             if (fLexicalHandler != null) {


1070 
1071                 // startEntity outputs only Text but not Element, Attr, Comment
1072                 // and PI child nodes.  It does so by setting the m_inEntityRef
1073                 // in ToStream and using this to decide if a node is to be
1074                 // serialized or not.
1075                 fLexicalHandler.startEntity(eref.getNodeName());
1076             }
1077 
1078         } else {
1079             EntityReference eref = node;
1080             // entities=true or false,
1081             if (fLexicalHandler != null) {
1082                 fLexicalHandler.endEntity(eref.getNodeName());
1083             }
1084         }
1085     }
1086 
1087 
1088     // ***********************************************************************
1089     // Methods to check well-formedness


   1 /*
   2  * Copyright (c) 2015, 2016 Oracle and/or its affiliates. All rights reserved.
   3  */
   4 /*
   5  * Licensed to the Apache Software Foundation (ASF) under one or more
   6  * contributor license agreements.  See the NOTICE file distributed with
   7  * this work for additional information regarding copyright ownership.
   8  * The ASF licenses this file to You under the Apache License, Version 2.0
   9  * (the "License"); you may not use this file except in compliance with
  10  * the License.  You may obtain a copy of the License at
  11  *
  12  *      http://www.apache.org/licenses/LICENSE-2.0
  13  *
  14  * Unless required by applicable law or agreed to in writing, software
  15  * distributed under the License is distributed on an "AS IS" BASIS,
  16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  17  * See the License for the specific language governing permissions and
  18  * limitations under the License.
  19  */
  20 
  21 package com.sun.org.apache.xml.internal.serializer.dom3;
  22 


 351 
 352                     if ((null == pos) || ((null != top) && top.equals(pos))) {
 353                         nextNode = null;
 354 
 355                         break;
 356                     }
 357                 }
 358             }
 359 
 360             pos = nextNode;
 361         }
 362         this.fSerializer.endDocument();
 363     }
 364 
 365     /**
 366      * Optimized dispatch of characters.
 367      */
 368     private final void dispatachChars(Node node)
 369         throws org.xml.sax.SAXException {
 370         if (fSerializer != null) {


 371             String data = ((Text) node).getData();
 372             this.fSerializer.characters(data.toCharArray(), 0, data.length());
 373         }
 374     }
 375 
 376     /**
 377      * Start processing given node
 378      *
 379      * @param node Node to process
 380      *
 381      * @throws org.xml.sax.SAXException
 382      */
 383     protected void startNode(Node node) throws org.xml.sax.SAXException {
 384         if (node instanceof Locator) {
 385             Locator loc = (Locator) node;
 386             fLocator.setColumnNumber(loc.getColumnNumber());
 387             fLocator.setLineNumber(loc.getLineNumber());
 388             fLocator.setPublicId(loc.getPublicId());
 389             fLocator.setSystemId(loc.getSystemId());
 390         } else {


1047 
1048                 // perform well-formedness and other checking only if
1049                 // entities = true
1050 
1051                 // well-formed=true
1052                 if ((fFeatures & WELLFORMED) != 0) {
1053                     isEntityReferneceWellFormed(node);
1054                 }
1055 
1056                 // check "unbound-prefix-in-entity-reference" [fatal]
1057                 // Raised if the configuration parameter "namespaces" is set to true
1058                 if ((fFeatures & NAMESPACES) != 0) {
1059                     checkUnboundPrefixInEntRef(node);
1060                 }
1061 
1062                 // The filter should not apply in this case, since the
1063                 // EntityReference is not being expanded.
1064                 // should we pass entity reference nodes to the filter???
1065             }
1066 
1067             // if "entities" is true, or EntityReference node has no children,
1068             // it will be serialized as the form "&entityName;" in the output.
1069             if (fLexicalHandler != null && ((fFeatures & ENTITIES) != 0 || !node.hasChildNodes())) {
1070 
1071                 // startEntity outputs only Text but not Element, Attr, Comment
1072                 // and PI child nodes.  It does so by setting the m_inEntityRef
1073                 // in ToStream and using this to decide if a node is to be
1074                 // serialized or not.
1075                 fLexicalHandler.startEntity(eref.getNodeName());
1076             }
1077 
1078         } else {
1079             EntityReference eref = node;
1080             // entities=true or false,
1081             if (fLexicalHandler != null) {
1082                 fLexicalHandler.endEntity(eref.getNodeName());
1083             }
1084         }
1085     }
1086 
1087 
1088     // ***********************************************************************
1089     // Methods to check well-formedness


< prev index next >