1 /*
2 * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
3 * @LastModified: Oct 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
233 MappingRecord map = new MappingRecord(prefix,uri,elemDepth);
234 stack.push(map);
235 m_nodeStack.push(map);
236 return true;
237 }
238
239 /**
240 * Pop, or undeclare all namespace definitions that are currently
241 * declared at the given element depth, or deepter.
242 * @param elemDepth the element depth for which mappings declared at this
243 * depth or deeper will no longer be valid
244 * @param saxHandler The ContentHandler to notify of any endPrefixMapping()
245 * calls. This parameter can be null.
246 */
247 void popNamespaces(int elemDepth, ContentHandler saxHandler)
248 {
249 while (true)
250 {
251 if (m_nodeStack.isEmpty())
252 return;
253 MappingRecord map = (MappingRecord)(m_nodeStack.peek());
254 int depth = map.m_declarationDepth;
255 if (depth < elemDepth)
256 return;
257 /* the depth of the declared mapping is elemDepth or deeper
258 * so get rid of it
259 */
260
261 map = (MappingRecord) m_nodeStack.pop();
262 final String prefix = map.m_prefix;
263 popNamespace(prefix);
264 if (saxHandler != null)
265 {
266 try
267 {
268 saxHandler.endPrefixMapping(prefix);
269 }
270 catch (SAXException e)
271 {
272 // not much we can do if they aren't willing to listen
273 }
274 }
275
276 }
277 }
278
279 /**
280 * Generate a new namespace prefix ( ns0, ns1 ...) not used before
281 * @return String a new namespace prefix ( ns0, ns1, ns2 ...)
|
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
233 MappingRecord map = new MappingRecord(prefix,uri,elemDepth);
234 stack.push(map);
235 m_nodeStack.push(map);
236 return true;
237 }
238
239 /**
240 * Pop, or undeclare all namespace definitions that are currently
241 * declared at the given element depth, or deepter.
242 * @param elemDepth the element depth for which mappings declared at this
243 * depth or deeper will no longer be valid
244 * @param saxHandler The ContentHandler to notify of any endPrefixMapping()
245 * calls. This parameter can be null.
246 */
247 void popNamespaces(int elemDepth, ContentHandler saxHandler)
248 {
249 while (true)
250 {
251 if (m_nodeStack.isEmpty())
252 return;
253 MappingRecord map = m_nodeStack.peek();
254 int depth = map.m_declarationDepth;
255 if (depth < elemDepth)
256 return;
257 /* the depth of the declared mapping is elemDepth or deeper
258 * so get rid of it
259 */
260
261 map = m_nodeStack.pop();
262 final String prefix = map.m_prefix;
263 popNamespace(prefix);
264 if (saxHandler != null)
265 {
266 try
267 {
268 saxHandler.endPrefixMapping(prefix);
269 }
270 catch (SAXException e)
271 {
272 // not much we can do if they aren't willing to listen
273 }
274 }
275
276 }
277 }
278
279 /**
280 * Generate a new namespace prefix ( ns0, ns1 ...) not used before
281 * @return String a new namespace prefix ( ns0, ns1, ns2 ...)
|