< prev index next >

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

Print this page


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


  44  * </chapter>
  45  * </pre>
  46  *
  47  * When the <chapter> element is encounted the prefix "p1" associated with uri
  48  * "def" is pushed on the stack with depth 1.
  49  * When the first <paragraph> is encountered "p2" and "ghi" are pushed with
  50  * depth 2.
  51  * When the <sentance> is encountered "p3" and "jkl" are pushed with depth 3.
  52  * When </sentance> occurs the popNamespaces(3) will pop "p3"/"jkl" off the
  53  * stack.  Of course popNamespaces(2) would pop anything with depth 2 or
  54  * greater.
  55  *
  56  * So prefix/uri pairs are pushed and poped off the stack as elements are
  57  * processed.  At any given moment of processing the currently visible prefixes
  58  * are on the stack and a prefix can be found given a uri, or a uri can be found
  59  * given a prefix.
  60  *
  61  * This class is public only because it is used by Xalan. It is not a public API
  62  *
  63  * @xsl.usage internal

  64  */
  65 public class NamespaceMappings
  66 {
  67     /**
  68      * This member is continually incremented when new prefixes need to be
  69      * generated. ("ns0"  "ns1" ...)
  70      */
  71     private int count;
  72 
  73     /**
  74      * Each entry (prefix) in this hashmap points to a Stack of URIs
  75      * This maps a prefix (String) to a Stack of prefix mappings.
  76      * All mappings in that retrieved stack have the same prefix,
  77      * though possibly different URI's or depths. Such a stack must have
  78      * mappings at deeper depths push later on such a stack.  Mappings pushed
  79      * earlier on the stack will have smaller values for MappingRecord.m_declarationDepth.
  80      */
  81     private HashMap<String, Stack<MappingRecord>> m_namespaces = new HashMap<>();
  82 
  83     /**


   1 /*
   2  * Copyright (c) 2017, 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;
  22 


  43  * </chapter>
  44  * </pre>
  45  *
  46  * When the <chapter> element is encounted the prefix "p1" associated with uri
  47  * "def" is pushed on the stack with depth 1.
  48  * When the first <paragraph> is encountered "p2" and "ghi" are pushed with
  49  * depth 2.
  50  * When the <sentance> is encountered "p3" and "jkl" are pushed with depth 3.
  51  * When </sentance> occurs the popNamespaces(3) will pop "p3"/"jkl" off the
  52  * stack.  Of course popNamespaces(2) would pop anything with depth 2 or
  53  * greater.
  54  *
  55  * So prefix/uri pairs are pushed and poped off the stack as elements are
  56  * processed.  At any given moment of processing the currently visible prefixes
  57  * are on the stack and a prefix can be found given a uri, or a uri can be found
  58  * given a prefix.
  59  *
  60  * This class is public only because it is used by Xalan. It is not a public API
  61  *
  62  * @xsl.usage internal
  63  * @LastModified: Nov 2017
  64  */
  65 public class NamespaceMappings
  66 {
  67     /**
  68      * This member is continually incremented when new prefixes need to be
  69      * generated. ("ns0"  "ns1" ...)
  70      */
  71     private int count;
  72 
  73     /**
  74      * Each entry (prefix) in this hashmap points to a Stack of URIs
  75      * This maps a prefix (String) to a Stack of prefix mappings.
  76      * All mappings in that retrieved stack have the same prefix,
  77      * though possibly different URI's or depths. Such a stack must have
  78      * mappings at deeper depths push later on such a stack.  Mappings pushed
  79      * earlier on the stack will have smaller values for MappingRecord.m_declarationDepth.
  80      */
  81     private HashMap<String, Stack<MappingRecord>> m_namespaces = new HashMap<>();
  82 
  83     /**


< prev index next >