--- old/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/ReferenceType.java 2017-06-14 09:27:36.830394292 -0700 +++ new/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/ReferenceType.java 2017-06-14 09:27:35.722339108 -0700 @@ -1,6 +1,5 @@ /* - * reserved comment block - * DO NOT REMOVE OR ALTER! + * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. */ /* * Licensed to the Apache Software Foundation (ASF) under one or more @@ -262,6 +261,7 @@ * @deprecated use getFirstCommonSuperclass(ReferenceType t) which has * slightly changed semantics. */ + @Deprecated public ReferenceType firstCommonSuperclass(ReferenceType t) { if (this.equals(Type.NULL)) return t; if (t.equals(Type.NULL)) return this; --- old/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/lib/ExsltSets.java 2017-06-14 09:27:58.175457344 -0700 +++ new/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/lib/ExsltSets.java 2017-06-14 09:27:57.215409530 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2017, Oracle and/or its affiliates. All rights reserved. */ /* * Licensed to the Apache Software Foundation (ASF) under one or more @@ -22,7 +22,7 @@ */ package com.sun.org.apache.xalan.internal.lib; -import com.sun.org.apache.xml.internal.utils.DOMHelper; +import com.sun.org.apache.xml.internal.utils.DOM2Helper; import com.sun.org.apache.xpath.internal.NodeSet; import java.util.HashMap; import java.util.Map; @@ -72,8 +72,8 @@ for (int i = 0; i < nl1.getLength(); i++) { Node testNode = nl1.item(i); - if (DOMHelper.isNodeAfter(testNode, endNode) - && !DOMHelper.isNodeTheSame(testNode, endNode)) + if (DOM2Helper.isNodeAfter(testNode, endNode) + && !DOM2Helper.isNodeTheSame(testNode, endNode)) leadNodes.addElement(testNode); } return leadNodes; @@ -107,8 +107,8 @@ for (int i = 0; i < nl1.getLength(); i++) { Node testNode = nl1.item(i); - if (DOMHelper.isNodeAfter(startNode, testNode) - && !DOMHelper.isNodeTheSame(startNode, testNode)) + if (DOM2Helper.isNodeAfter(startNode, testNode) + && !DOM2Helper.isNodeTheSame(startNode, testNode)) trailNodes.addElement(testNode); } return trailNodes; --- old/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/res/XSLTErrorResources.java 2017-06-14 09:28:19.724530561 -0700 +++ new/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/res/XSLTErrorResources.java 2017-06-14 09:28:18.748481952 -0700 @@ -1,6 +1,5 @@ /* - * reserved comment block - * DO NOT REMOVE OR ALTER! + * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. */ /* * Licensed to the Apache Software Foundation (ASF) under one or more @@ -22,9 +21,6 @@ package com.sun.org.apache.xalan.internal.res; import java.util.ListResourceBundle; -import java.util.Locale; -import java.util.MissingResourceException; -import java.util.ResourceBundle; /** * Set up error messages. @@ -1426,24 +1422,4 @@ /** String for use when formatting of the error string failed. */ public static final String FORMAT_FAILED = "FORMAT_FAILED"; - /** General error string. */ - public static final String ERROR_STRING = "#error"; - - /** String to prepend to error messages. */ - public static final String ERROR_HEADER = "Error: "; - - /** String to prepend to warning messages. */ - public static final String WARNING_HEADER = "Warning: "; - - /** String to specify the XSLT module. */ - public static final String XSL_HEADER = "XSLT "; - - /** String to specify the XML parser module. */ - public static final String XML_HEADER = "XML "; - - /** I don't think this is used any more. - * @deprecated */ - public static final String QUERY_HEADER = "PATTERN "; - - } --- old/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/res/XSLTErrorResources_de.java 2017-06-14 09:28:42.393659538 -0700 +++ new/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/res/XSLTErrorResources_de.java 2017-06-14 09:28:41.209600596 -0700 @@ -1,6 +1,5 @@ /* - * reserved comment block - * DO NOT REMOVE OR ALTER! + * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. */ /* * Licensed to the Apache Software Foundation (ASF) under one or more @@ -22,9 +21,6 @@ package com.sun.org.apache.xalan.internal.res; import java.util.ListResourceBundle; -import java.util.Locale; -import java.util.MissingResourceException; -import java.util.ResourceBundle; /** * Set up error messages. @@ -1426,24 +1422,4 @@ /** String for use when formatting of the error string failed. */ public static final String FORMAT_FAILED = "FORMAT_FAILED"; - /** General error string. */ - public static final String ERROR_STRING = "#error"; - - /** String to prepend to error messages. */ - public static final String ERROR_HEADER = "Error: "; - - /** String to prepend to warning messages. */ - public static final String WARNING_HEADER = "Warning: "; - - /** String to specify the XSLT module. */ - public static final String XSL_HEADER = "XSLT "; - - /** String to specify the XML parser module. */ - public static final String XML_HEADER = "XML "; - - /** I don't think this is used any more. - * @deprecated */ - public static final String QUERY_HEADER = "PATTERN "; - - - } +} --- old/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/res/XSLTErrorResources_es.java 2017-06-14 09:29:10.871077850 -0700 +++ new/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/res/XSLTErrorResources_es.java 2017-06-14 09:29:09.879028442 -0700 @@ -1,6 +1,5 @@ /* - * reserved comment block - * DO NOT REMOVE OR ALTER! + * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. */ /* * Licensed to the Apache Software Foundation (ASF) under one or more @@ -22,9 +21,6 @@ package com.sun.org.apache.xalan.internal.res; import java.util.ListResourceBundle; -import java.util.Locale; -import java.util.MissingResourceException; -import java.util.ResourceBundle; /** * Set up error messages. @@ -1425,25 +1421,4 @@ /** String for use when formatting of the error string failed. */ public static final String FORMAT_FAILED = "FORMAT_FAILED"; - - /** General error string. */ - public static final String ERROR_STRING = "#error"; - - /** String to prepend to error messages. */ - public static final String ERROR_HEADER = "Error: "; - - /** String to prepend to warning messages. */ - public static final String WARNING_HEADER = "Warning: "; - - /** String to specify the XSLT module. */ - public static final String XSL_HEADER = "XSLT "; - - /** String to specify the XML parser module. */ - public static final String XML_HEADER = "XML "; - - /** I don't think this is used any more. - * @deprecated */ - public static final String QUERY_HEADER = "PATTERN "; - - } --- old/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/res/XSLTErrorResources_fr.java 2017-06-14 09:29:39.384497950 -0700 +++ new/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/res/XSLTErrorResources_fr.java 2017-06-14 09:29:38.248441353 -0700 @@ -1,6 +1,5 @@ /* - * reserved comment block - * DO NOT REMOVE OR ALTER! + * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. */ /* * Licensed to the Apache Software Foundation (ASF) under one or more @@ -22,9 +21,6 @@ package com.sun.org.apache.xalan.internal.res; import java.util.ListResourceBundle; -import java.util.Locale; -import java.util.MissingResourceException; -import java.util.ResourceBundle; /** * Set up error messages. @@ -1425,25 +1421,4 @@ /** String for use when formatting of the error string failed. */ public static final String FORMAT_FAILED = "FORMAT_FAILED"; - - /** General error string. */ - public static final String ERROR_STRING = "#error"; - - /** String to prepend to error messages. */ - public static final String ERROR_HEADER = "Error: "; - - /** String to prepend to warning messages. */ - public static final String WARNING_HEADER = "Warning: "; - - /** String to specify the XSLT module. */ - public static final String XSL_HEADER = "XSLT "; - - /** String to specify the XML parser module. */ - public static final String XML_HEADER = "XML "; - - /** I don't think this is used any more. - * @deprecated */ - public static final String QUERY_HEADER = "PATTERN "; - - - } +} --- old/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/res/XSLTErrorResources_it.java 2017-06-14 09:30:02.797664008 -0700 +++ new/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/res/XSLTErrorResources_it.java 2017-06-14 09:30:01.777613205 -0700 @@ -1,6 +1,5 @@ /* - * reserved comment block - * DO NOT REMOVE OR ALTER! + * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. */ /* * Licensed to the Apache Software Foundation (ASF) under one or more @@ -22,9 +21,6 @@ package com.sun.org.apache.xalan.internal.res; import java.util.ListResourceBundle; -import java.util.Locale; -import java.util.MissingResourceException; -import java.util.ResourceBundle; /** * Set up error messages. @@ -1425,25 +1421,4 @@ /** String for use when formatting of the error string failed. */ public static final String FORMAT_FAILED = "FORMAT_FAILED"; - - /** General error string. */ - public static final String ERROR_STRING = "#error"; - - /** String to prepend to error messages. */ - public static final String ERROR_HEADER = "Error: "; - - /** String to prepend to warning messages. */ - public static final String WARNING_HEADER = "Warning: "; - - /** String to specify the XSLT module. */ - public static final String XSL_HEADER = "XSLT "; - - /** String to specify the XML parser module. */ - public static final String XML_HEADER = "XML "; - - /** I don't think this is used any more. - * @deprecated */ - public static final String QUERY_HEADER = "PATTERN "; - - - } +} --- old/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/res/XSLTErrorResources_ja.java 2017-06-14 09:30:24.426741232 -0700 +++ new/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/res/XSLTErrorResources_ja.java 2017-06-14 09:30:23.410690628 -0700 @@ -1,6 +1,5 @@ /* - * reserved comment block - * DO NOT REMOVE OR ALTER! + * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. */ /* * Licensed to the Apache Software Foundation (ASF) under one or more @@ -22,9 +21,6 @@ package com.sun.org.apache.xalan.internal.res; import java.util.ListResourceBundle; -import java.util.Locale; -import java.util.MissingResourceException; -import java.util.ResourceBundle; /** * Set up error messages. @@ -1425,25 +1421,4 @@ /** String for use when formatting of the error string failed. */ public static final String FORMAT_FAILED = "FORMAT_FAILED"; - - /** General error string. */ - public static final String ERROR_STRING = "#error"; - - /** String to prepend to error messages. */ - public static final String ERROR_HEADER = "Error: "; - - /** String to prepend to warning messages. */ - public static final String WARNING_HEADER = "Warning: "; - - /** String to specify the XSLT module. */ - public static final String XSL_HEADER = "XSLT "; - - /** String to specify the XML parser module. */ - public static final String XML_HEADER = "XML "; - - /** I don't think this is used any more. - * @deprecated */ - public static final String QUERY_HEADER = "PATTERN "; - - - } +} --- old/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/res/XSLTErrorResources_ko.java 2017-06-14 09:30:48.291929828 -0700 +++ new/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/res/XSLTErrorResources_ko.java 2017-06-14 09:30:47.243877630 -0700 @@ -1,6 +1,5 @@ /* - * reserved comment block - * DO NOT REMOVE OR ALTER! + * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. */ /* * Licensed to the Apache Software Foundation (ASF) under one or more @@ -22,9 +21,6 @@ package com.sun.org.apache.xalan.internal.res; import java.util.ListResourceBundle; -import java.util.Locale; -import java.util.MissingResourceException; -import java.util.ResourceBundle; /** * Set up error messages. @@ -1015,7 +1011,7 @@ "\uC2DC\uC2A4\uD15C \uC18D\uC131 org.xml.sax.parser\uAC00 \uC9C0\uC815\uB418\uC9C0 \uC54A\uC558\uC2B5\uB2C8\uB2E4."}, { ER_PARSER_ARG_CANNOT_BE_NULL, - "\uAD6C\uBB38\uBD84\uC11D\uAE30 \uC778\uC218\uB294 \uB110\uC774 \uC544\uB2C8\uC5B4\uC57C \uD569\uB2C8\uB2E4."}, + "\uAD6C\uBB38 \uBD84\uC11D\uAE30 \uC778\uC218\uB294 \uB110\uC774 \uC544\uB2C8\uC5B4\uC57C \uD569\uB2C8\uB2E4."}, { ER_FEATURE, "\uAE30\uB2A5: {0}"}, @@ -1252,7 +1248,7 @@ "\uD2B9\uC218 \uCDA9\uB3CC\uC774 \uBC1C\uACAC\uB428: {0}. \uC2A4\uD0C0\uC77C\uC2DC\uD2B8\uC5D0\uC11C \uBC1C\uACAC\uB41C \uB9C8\uC9C0\uB9C9 \uD56D\uBAA9\uC774 \uC0AC\uC6A9\uB429\uB2C8\uB2E4."}, { WG_PARSING_AND_PREPARING, - "========= \uAD6C\uBB38\uBD84\uC11D \uD6C4 {0} \uC900\uBE44 \uC911 =========="}, + "========= \uAD6C\uBB38 \uBD84\uC11D \uD6C4 {0} \uC900\uBE44 \uC911 =========="}, { WG_ATTR_TEMPLATE, "\uC18D\uC131 \uD15C\uD50C\uB9AC\uD2B8, {0}"}, @@ -1357,7 +1353,7 @@ { "optionOUT", " [-OUT outputFileName]"}, { "optionLXCIN", " [-LXCIN compiledStylesheetFileNameIn]"}, { "optionLXCOUT", " [-LXCOUT compiledStylesheetFileNameOutOut]"}, - { "optionPARSER", " [-PARSER \uAD6C\uBB38\uBD84\uC11D\uAE30 \uC5F0\uACB0\uC758 \uC804\uCCB4 \uD074\uB798\uC2A4 \uC774\uB984]"}, + { "optionPARSER", " [-PARSER \uAD6C\uBB38 \uBD84\uC11D\uAE30 \uC5F0\uACB0\uC758 \uC804\uCCB4 \uD074\uB798\uC2A4 \uC774\uB984]"}, { "optionE", " [-E(\uC5D4\uD2F0\uD2F0 \uCC38\uC870 \uD655\uC7A5 \uC548\uD568)]"}, { "optionV", " [-E(\uC5D4\uD2F0\uD2F0 \uCC38\uC870 \uD655\uC7A5 \uC548\uD568)]"}, { "optionQC", " [-QC(\uC790\uB3D9 \uD328\uD134 \uCDA9\uB3CC \uACBD\uACE0)]"}, @@ -1378,9 +1374,9 @@ { "optionHTML", " [-HTML(HTML \uD3EC\uB9F7\uD130 \uC0AC\uC6A9)]"}, { "optionPARAM", " [-PARAM \uC774\uB984 \uD45C\uD604\uC2DD(\uC2A4\uD0C0\uC77C\uC2DC\uD2B8 \uB9E4\uAC1C\uBCC0\uC218 \uC124\uC815)]"}, { "noParsermsg1", "XSL \uD504\uB85C\uC138\uC2A4\uB97C \uC2E4\uD328\uD588\uC2B5\uB2C8\uB2E4."}, - { "noParsermsg2", "** \uAD6C\uBB38\uBD84\uC11D\uAE30\uB97C \uCC3E\uC744 \uC218 \uC5C6\uC74C **"}, + { "noParsermsg2", "** \uAD6C\uBB38 \uBD84\uC11D\uAE30\uB97C \uCC3E\uC744 \uC218 \uC5C6\uC74C **"}, { "noParsermsg3", "\uD074\uB798\uC2A4 \uACBD\uB85C\uB97C \uD655\uC778\uD558\uC2ED\uC2DC\uC624."}, - { "noParsermsg4", "IBM\uC758 Java\uC6A9 XML \uAD6C\uBB38\uBD84\uC11D\uAE30\uAC00 \uC5C6\uC744 \uACBD\uC6B0 \uB2E4\uC74C \uC704\uCE58\uC5D0\uC11C \uB2E4\uC6B4\uB85C\uB4DC\uD560 \uC218 \uC788\uC2B5\uB2C8\uB2E4."}, + { "noParsermsg4", "IBM\uC758 Java\uC6A9 XML \uAD6C\uBB38 \uBD84\uC11D\uAE30\uAC00 \uC5C6\uC744 \uACBD\uC6B0 \uB2E4\uC74C \uC704\uCE58\uC5D0\uC11C \uB2E4\uC6B4\uB85C\uB4DC\uD560 \uC218 \uC788\uC2B5\uB2C8\uB2E4."}, { "noParsermsg5", "IBM AlphaWorks: http://www.alphaworks.ibm.com/formula/xml"}, { "optionURIRESOLVER", " [-URIRESOLVER \uC804\uCCB4 \uD074\uB798\uC2A4 \uC774\uB984(URI \uBD84\uC11D\uC5D0 \uC0AC\uC6A9\uD560 URIResolver)]"}, { "optionENTITYRESOLVER", " [-ENTITYRESOLVER \uC804\uCCB4 \uD074\uB798\uC2A4 \uC774\uB984(\uC5D4\uD2F0\uD2F0 \uBD84\uC11D\uC5D0 \uC0AC\uC6A9\uD560 EntityResolver)]"}, @@ -1425,25 +1421,4 @@ /** String for use when formatting of the error string failed. */ public static final String FORMAT_FAILED = "FORMAT_FAILED"; - - /** General error string. */ - public static final String ERROR_STRING = "#error"; - - /** String to prepend to error messages. */ - public static final String ERROR_HEADER = "Error: "; - - /** String to prepend to warning messages. */ - public static final String WARNING_HEADER = "Warning: "; - - /** String to specify the XSLT module. */ - public static final String XSL_HEADER = "XSLT "; - - /** String to specify the XML parser module. */ - public static final String XML_HEADER = "XML "; - - /** I don't think this is used any more. - * @deprecated */ - public static final String QUERY_HEADER = "PATTERN "; - - - } +} --- old/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/res/XSLTErrorResources_pt_BR.java 2017-06-14 09:31:11.641092728 -0700 +++ new/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/res/XSLTErrorResources_pt_BR.java 2017-06-14 09:31:10.709046307 -0700 @@ -1,6 +1,5 @@ /* - * reserved comment block - * DO NOT REMOVE OR ALTER! + * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. */ /* * Licensed to the Apache Software Foundation (ASF) under one or more @@ -22,9 +21,6 @@ package com.sun.org.apache.xalan.internal.res; import java.util.ListResourceBundle; -import java.util.Locale; -import java.util.MissingResourceException; -import java.util.ResourceBundle; /** * Set up error messages. @@ -1425,25 +1421,4 @@ /** String for use when formatting of the error string failed. */ public static final String FORMAT_FAILED = "FORMAT_FAILED"; - - /** General error string. */ - public static final String ERROR_STRING = "#error"; - - /** String to prepend to error messages. */ - public static final String ERROR_HEADER = "Error: "; - - /** String to prepend to warning messages. */ - public static final String WARNING_HEADER = "Warning: "; - - /** String to specify the XSLT module. */ - public static final String XSL_HEADER = "XSLT "; - - /** String to specify the XML parser module. */ - public static final String XML_HEADER = "XML "; - - /** I don't think this is used any more. - * @deprecated */ - public static final String QUERY_HEADER = "PATTERN "; - - - } +} --- old/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/res/XSLTErrorResources_sv.java 2017-06-14 09:31:32.802146654 -0700 +++ new/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/res/XSLTErrorResources_sv.java 2017-06-14 09:31:31.810097245 -0700 @@ -1,6 +1,5 @@ /* - * reserved comment block - * DO NOT REMOVE OR ALTER! + * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. */ /* * Licensed to the Apache Software Foundation (ASF) under one or more @@ -22,9 +21,6 @@ package com.sun.org.apache.xalan.internal.res; import java.util.ListResourceBundle; -import java.util.Locale; -import java.util.MissingResourceException; -import java.util.ResourceBundle; /** * Set up error messages. @@ -482,7 +478,7 @@ {"ER0000" , "{0}" }, { ER_NO_CURLYBRACE, - "Fel: Uttryck f\u00E5r inte inneh\u00E5lla '{'"}, + "Fel: Uttryck kan inte inneh\u00E5lla '{'"}, { ER_ILLEGAL_ATTRIBUTE , "{0} har ett otill\u00E5tet attribut: {1}"}, @@ -1426,24 +1422,4 @@ /** String for use when formatting of the error string failed. */ public static final String FORMAT_FAILED = "FORMAT_FAILED"; - /** General error string. */ - public static final String ERROR_STRING = "#error"; - - /** String to prepend to error messages. */ - public static final String ERROR_HEADER = "Error: "; - - /** String to prepend to warning messages. */ - public static final String WARNING_HEADER = "Warning: "; - - /** String to specify the XSLT module. */ - public static final String XSL_HEADER = "XSLT "; - - /** String to specify the XML parser module. */ - public static final String XML_HEADER = "XML "; - - /** I don't think this is used any more. - * @deprecated */ - public static final String QUERY_HEADER = "PATTERN "; - - - } +} --- old/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/res/XSLTErrorResources_zh_CN.java 2017-06-14 09:31:54.211212931 -0700 +++ new/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/res/XSLTErrorResources_zh_CN.java 2017-06-14 09:31:53.259165518 -0700 @@ -1,6 +1,5 @@ /* - * reserved comment block - * DO NOT REMOVE OR ALTER! + * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. */ /* * Licensed to the Apache Software Foundation (ASF) under one or more @@ -22,9 +21,6 @@ package com.sun.org.apache.xalan.internal.res; import java.util.ListResourceBundle; -import java.util.Locale; -import java.util.MissingResourceException; -import java.util.ResourceBundle; /** * Set up error messages. @@ -1425,25 +1421,4 @@ /** String for use when formatting of the error string failed. */ public static final String FORMAT_FAILED = "FORMAT_FAILED"; - - /** General error string. */ - public static final String ERROR_STRING = "#error"; - - /** String to prepend to error messages. */ - public static final String ERROR_HEADER = "Error: "; - - /** String to prepend to warning messages. */ - public static final String WARNING_HEADER = "Warning: "; - - /** String to specify the XSLT module. */ - public static final String XSL_HEADER = "XSLT "; - - /** String to specify the XML parser module. */ - public static final String XML_HEADER = "XML "; - - /** I don't think this is used any more. - * @deprecated */ - public static final String QUERY_HEADER = "PATTERN "; - - - } +} --- old/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/res/XSLTErrorResources_zh_TW.java 2017-06-14 09:32:17.884391985 -0700 +++ new/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/res/XSLTErrorResources_zh_TW.java 2017-06-14 09:32:16.928344369 -0700 @@ -1,6 +1,5 @@ /* - * reserved comment block - * DO NOT REMOVE OR ALTER! + * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. */ /* * Licensed to the Apache Software Foundation (ASF) under one or more @@ -22,9 +21,6 @@ package com.sun.org.apache.xalan.internal.res; import java.util.ListResourceBundle; -import java.util.Locale; -import java.util.MissingResourceException; -import java.util.ResourceBundle; /** * Set up error messages. @@ -1425,25 +1421,4 @@ /** String for use when formatting of the error string failed. */ public static final String FORMAT_FAILED = "FORMAT_FAILED"; - - /** General error string. */ - public static final String ERROR_STRING = "#error"; - - /** String to prepend to error messages. */ - public static final String ERROR_HEADER = "Error: "; - - /** String to prepend to warning messages. */ - public static final String WARNING_HEADER = "Warning: "; - - /** String to specify the XSLT module. */ - public static final String XSL_HEADER = "XSLT "; - - /** String to specify the XML parser module. */ - public static final String XML_HEADER = "XML "; - - /** I don't think this is used any more. - * @deprecated */ - public static final String QUERY_HEADER = "PATTERN "; - - - } +} --- old/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/dom/ForwardPositionIterator.java 2017-06-14 09:32:40.845535576 -0700 +++ new/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/dom/ForwardPositionIterator.java 2017-06-14 09:32:39.829484971 -0700 @@ -1,6 +1,5 @@ /* - * reserved comment block - * DO NOT REMOVE OR ALTER! + * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. */ /* * Licensed to the Apache Software Foundation (ASF) under one or more @@ -60,6 +59,7 @@ * @deprecated This class exists only for backwards compatibility with old * translets. New code should not reference it. */ +@Deprecated public final class ForwardPositionIterator extends DTMAxisIteratorBase { private DTMAxisIterator _source; --- old/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/dom/KeyIndex.java 2017-06-14 09:33:09.354955507 -0700 +++ new/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/dom/KeyIndex.java 2017-06-14 09:33:08.338904902 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2017, Oracle and/or its affiliates. All rights reserved. */ /* * Licensed to the Apache Software Foundation (ASF) under one or more @@ -115,6 +115,7 @@ * Merge the current value's nodeset set by lookupKey() with _nodes. * @deprecated */ + @Deprecated public void merge(KeyIndex other) { if (other == null) return; @@ -136,6 +137,7 @@ * key() function. * @deprecated */ + @Deprecated public void lookupId(Object value) { // Clear _nodes array _nodes = null; @@ -205,6 +207,7 @@ * deprecated.

* @deprecated */ + @Deprecated public void lookupKey(Object value) { IntegerArray nodes = _index.get(value); _nodes = (nodes != null) ? (IntegerArray) nodes.clone() : null; @@ -217,6 +220,7 @@ * deprecated.

* @deprecated */ + @Deprecated public int next() { if (_nodes == null) return DTMAxisIterator.END; @@ -313,6 +317,7 @@ * deprecated.

* @deprecated */ + @Deprecated public DTMAxisIterator reset() { _position = 0; return this; @@ -324,6 +329,7 @@ * deprecated.

* @deprecated */ + @Deprecated public int getLast() { return (_nodes == null) ? 0 : _nodes.cardinality(); } @@ -334,6 +340,7 @@ * deprecated.

* @deprecated */ + @Deprecated public int getPosition() { return _position; } @@ -344,6 +351,7 @@ * deprecated.

* @deprecated */ + @Deprecated public void setMark() { _markedPosition = _position; } @@ -354,6 +362,7 @@ * deprecated.

* @deprecated */ + @Deprecated public void gotoMark() { _position = _markedPosition; } @@ -365,6 +374,7 @@ * deprecated.

* @deprecated */ + @Deprecated public DTMAxisIterator setStartNode(int start) { if (start == DTMAxisIterator.END) { _nodes = null; @@ -382,6 +392,7 @@ * deprecated.

* @deprecated */ + @Deprecated public int getStartNode() { return 0; } @@ -392,6 +403,7 @@ * deprecated.

* @deprecated */ + @Deprecated public boolean isReverse() { return(false); } @@ -402,6 +414,7 @@ * deprecated.

* @deprecated */ + @Deprecated public DTMAxisIterator cloneIterator() { KeyIndex other = new KeyIndex(0); other._index = _index; --- old/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/dom/NodeSortRecord.java 2017-06-14 09:33:43.304646402 -0700 +++ new/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/dom/NodeSortRecord.java 2017-06-14 09:33:42.388600778 -0700 @@ -1,6 +1,5 @@ /* - * reserved comment block - * DO NOT REMOVE OR ALTER! + * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. */ /* * Licensed to the Apache Software Foundation (ASF) under one or more @@ -49,6 +48,7 @@ * @deprecated This field continues to exist for binary compatibility. * New code should not refer to it. */ + @Deprecated private static final Collator DEFAULT_COLLATOR = Collator.getInstance(); /** @@ -56,6 +56,7 @@ * @deprecated This field continues to exist for binary compatibility. * New code should not refer to it. */ + @Deprecated protected Collator _collator = DEFAULT_COLLATOR; protected Collator[] _collators; @@ -64,6 +65,7 @@ * @deprecated This field continues to exist for binary compatibility. * New code should not refer to it. */ + @Deprecated protected Locale _locale; protected CollatorFactory _collatorFactory; --- old/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/dom/NodeSortRecordFactory.java 2017-06-14 09:34:06.009778072 -0700 +++ new/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/dom/NodeSortRecordFactory.java 2017-06-14 09:34:04.989727104 -0700 @@ -1,6 +1,5 @@ /* - * reserved comment block - * DO NOT REMOVE OR ALTER! + * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. */ /* * Licensed to the Apache Software Foundation (ASF) under one or more @@ -55,6 +54,7 @@ * @deprecated This constructor is no longer used in generated code. It * exists only for backwards compatibility. */ + @Deprecated public NodeSortRecordFactory(DOM dom, String className, Translet translet, String order[], String type[]) throws TransletException --- old/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/runtime/BasisLibrary.java 2017-06-14 09:34:28.258889789 -0700 +++ new/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/runtime/BasisLibrary.java 2017-06-14 09:34:27.222838021 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2017, Oracle and/or its affiliates. All rights reserved. */ /* * Licensed to the Apache Software Foundation (ASF) under one or more @@ -100,6 +100,7 @@ * @deprecated This method exists only for backwards compatibility with old * translets. New code should not reference it. */ + @Deprecated public static int positionF(DTMAxisIterator iterator) { return iterator.isReverse() ? iterator.getLast() - iterator.getPosition() + 1 --- old/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/dom/AttrImpl.java 2017-06-14 09:34:52.460099030 -0700 +++ new/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/dom/AttrImpl.java 2017-06-14 09:34:51.408046467 -0700 @@ -1,6 +1,5 @@ /* - * reserved comment block - * DO NOT REMOVE OR ALTER! + * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. */ /* * Licensed to the Apache Software Foundation (ASF) under one or more @@ -516,6 +515,7 @@ * @deprecated Previous working draft of DOM Level 2. New method * is getOwnerElement(). */ + @Deprecated public Element getElement() { // if we have an owner, ownerNode is our ownerElement, otherwise it's // our ownerDocument and we don't have an ownerElement --- old/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/dom/CoreDocumentImpl.java 2017-06-14 09:35:16.401295262 -0700 +++ new/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/dom/CoreDocumentImpl.java 2017-06-14 09:35:15.381244306 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009, 2017, Oracle and/or its affiliates. All rights reserved. */ /* * Licensed to the Apache Software Foundation (ASF) under one or more @@ -832,6 +832,7 @@ * compatibility with older applications. New applications * should never call this method. */ + @Deprecated public void setEncoding(String value) { setXmlEncoding(value); } @@ -849,6 +850,7 @@ * compatibility with older applications. New applications * should never call this method. */ + @Deprecated public String getEncoding() { return getXmlEncoding(); } @@ -890,6 +892,7 @@ * compatibility with older applications. New applications * should never call this method. */ + @Deprecated public void setVersion(String value) { setXmlVersion(value); } @@ -908,6 +911,7 @@ * compatibility with older applications. New applications * should never call this method. */ + @Deprecated public String getVersion() { return getXmlVersion(); } @@ -932,6 +936,7 @@ * compatibility with older applications. New applications * should never call this method. */ + @Deprecated public void setStandalone(boolean value) { setXmlStandalone(value); } @@ -950,6 +955,7 @@ * compatibility with older applications. New applications * should never call this method. */ + @Deprecated public boolean getStandalone() { return getXmlStandalone(); } --- old/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/dom/DeferredDocumentImpl.java 2017-06-14 09:35:38.094379173 -0700 +++ new/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/dom/DeferredDocumentImpl.java 2017-06-14 09:35:37.138331404 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2017 Oracle and/or its affiliates. All rights reserved. */ /* * Licensed to the Apache Software Foundation (ASF) under one or more @@ -369,6 +369,7 @@ * Creates an element node with a URI in the table and type information. * @deprecated */ + @Deprecated public int createDeferredElement(String elementURI, String elementName, Object type) { @@ -389,6 +390,7 @@ * Creates an element node in the table. * @deprecated */ + @Deprecated public int createDeferredElement(String elementName) { return createDeferredElement(null, elementName); } @@ -474,6 +476,7 @@ * Sets an attribute on an element node. * @deprecated */ + @Deprecated public int setDeferredAttribute(int elementNodeIndex, String attrName, String attrURI, String attrValue, boolean specified) { --- old/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/dom/NodeImpl.java 2017-06-14 09:35:59.867467065 -0700 +++ new/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/dom/NodeImpl.java 2017-06-14 09:35:58.955421492 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2017 Oracle and/or its affiliates. All rights reserved. */ /* * Licensed to the Apache Software Foundation (ASF) under one or more @@ -763,6 +763,7 @@ * @since DOM Level 3 * @deprecated */ + @Deprecated public short compareTreePosition(Node other) { // Questions of clarification for this method - to be answered by the // DOM WG. Current assumptions listed - LM --- old/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/xs/ItemPSVI.java 2017-06-14 09:36:21.236534755 -0700 +++ new/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/xs/ItemPSVI.java 2017-06-14 09:36:20.300487988 -0700 @@ -1,6 +1,5 @@ /* - * reserved comment block - * DO NOT REMOVE OR ALTER! + * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. */ /* * Licensed to the Apache Software Foundation (ASF) under one or more @@ -116,6 +115,7 @@ * * @deprecated Use getSchemaValue().getNormalizedValue() instead */ + @Deprecated public String getSchemaNormalizedValue(); /** @@ -127,6 +127,7 @@ * * @deprecated Use getSchemaValue().getActualValue() instead */ + @Deprecated public Object getActualNormalizedValue() throws XSException; @@ -146,6 +147,7 @@ * * @deprecated Use getSchemaValue().getActualValueType() instead */ + @Deprecated public short getActualNormalizedValueType() throws XSException; @@ -182,6 +184,7 @@ * * @deprecated Use getSchemaValue().getListValueTypes() instead */ + @Deprecated public ShortList getItemValueTypes() throws XSException; --- old/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/xs/XSAttributeDeclaration.java 2017-06-14 09:36:47.265835283 -0700 +++ new/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/xs/XSAttributeDeclaration.java 2017-06-14 09:36:46.309787515 -0700 @@ -1,6 +1,5 @@ /* - * reserved comment block - * DO NOT REMOVE OR ALTER! + * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. */ /* * Licensed to the Apache Software Foundation (ASF) under one or more @@ -55,6 +54,7 @@ * * @deprecated Use getValueConstraintValue().getNormalizedValue() instead */ + @Deprecated public String getConstraintValue(); /** @@ -67,6 +67,7 @@ * * @deprecated Use getValueConstraintValue().getActualValue() instead */ + @Deprecated public Object getActualVC() throws XSException; @@ -86,6 +87,7 @@ * * @deprecated Use getValueConstraintValue().getActualValueType() instead */ + @Deprecated public short getActualVCType() throws XSException; @@ -104,6 +106,7 @@ * * @deprecated Use getValueConstraintValue().getListValueTypes() instead */ + @Deprecated public ShortList getItemValueTypes() throws XSException; --- old/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/xs/XSAttributeUse.java 2017-06-14 09:37:09.926967511 -0700 +++ new/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/xs/XSAttributeUse.java 2017-06-14 09:37:08.958919144 -0700 @@ -1,6 +1,5 @@ /* - * reserved comment block - * DO NOT REMOVE OR ALTER! + * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. */ /* * Licensed to the Apache Software Foundation (ASF) under one or more @@ -48,6 +47,7 @@ * * @deprecated Use getValueConstraintValue().getNormalizedValue() instead */ + @Deprecated public String getConstraintValue(); /** @@ -60,6 +60,7 @@ * * @deprecated Use getValueConstraintValue().getActualValue() instead */ + @Deprecated public Object getActualVC() throws XSException; @@ -79,6 +80,7 @@ * * @deprecated Use getValueConstraintValue().getActualValueType() instead */ + @Deprecated public short getActualVCType() throws XSException; @@ -97,6 +99,7 @@ * * @deprecated Use getValueConstraintValue().getListValueTypes() instead */ + @Deprecated public ShortList getItemValueTypes() throws XSException; --- old/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/xs/XSElementDeclaration.java 2017-06-14 09:37:37.304335366 -0700 +++ new/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/xs/XSElementDeclaration.java 2017-06-14 09:37:36.408290595 -0700 @@ -1,6 +1,5 @@ /* - * reserved comment block - * DO NOT REMOVE OR ALTER! + * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. */ /* * Licensed to the Apache Software Foundation (ASF) under one or more @@ -56,6 +55,7 @@ * * @deprecated Use getValueConstraintValue().getNormalizedValue() instead */ + @Deprecated public String getConstraintValue(); /** @@ -68,6 +68,7 @@ * * @deprecated Use getValueConstraintValue().getActualValue() instead */ + @Deprecated public Object getActualVC() throws XSException; @@ -87,6 +88,7 @@ * * @deprecated Use getValueConstraintValue().getActualValueType() instead */ + @Deprecated public short getActualVCType() throws XSException; @@ -105,6 +107,7 @@ * * @deprecated Use getValueConstraintValue().getListValueTypes() instead */ + @Deprecated public ShortList getItemValueTypes() throws XSException; --- old/src/java.xml/share/classes/com/sun/org/apache/xml/internal/dtm/ref/CoroutineParser.java 2017-06-14 09:37:58.769407813 -0700 +++ new/src/java.xml/share/classes/com/sun/org/apache/xml/internal/dtm/ref/CoroutineParser.java 2017-06-14 09:37:57.829360846 -0700 @@ -1,6 +1,5 @@ /* - * reserved comment block - * DO NOT REMOVE OR ALTER! + * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. */ /* * Licensed to the Apache Software Foundation (ASF) under one or more @@ -45,6 +44,7 @@ * coroutine protocol was not being used and was complicating design. * See {@link IncrementalSAXSource}. * */ +@Deprecated public interface CoroutineParser { /** @return the coroutine ID number for this CoroutineParser object. --- old/src/java.xml/share/classes/com/sun/org/apache/xml/internal/serialize/BaseMarkupSerializer.java 2017-06-14 09:38:20.102473655 -0700 +++ new/src/java.xml/share/classes/com/sun/org/apache/xml/internal/serialize/BaseMarkupSerializer.java 2017-06-14 09:38:19.150426091 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2017 Oracle and/or its affiliates. All rights reserved. */ /* * Licensed to the Apache Software Foundation (ASF) under one or more @@ -128,6 +128,7 @@ * {@link com.sun.org.apache.xml.internal.serialize.DOMSerializerImpl} is replaced * by {@link com.sun.org.apache.xml.internal.serializer.dom3.LSSerializerImpl}. */ +@Deprecated public abstract class BaseMarkupSerializer implements ContentHandler, DocumentHandler, LexicalHandler, DTDHandler, DeclHandler, DOMSerializer, Serializer --- old/src/java.xml/share/classes/com/sun/org/apache/xml/internal/serialize/DOMSerializer.java 2017-06-14 09:38:41.055520506 -0700 +++ new/src/java.xml/share/classes/com/sun/org/apache/xml/internal/serialize/DOMSerializer.java 2017-06-14 09:38:40.155475538 -0700 @@ -1,6 +1,5 @@ /* - * reserved comment block - * DO NOT REMOVE OR ALTER! + * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. */ /* * Licensed to the Apache Software Foundation (ASF) under one or more @@ -42,6 +41,7 @@ * {@link com.sun.org.apache.xml.internal.serialize.DOMSerializerImpl} is replaced * by {@link com.sun.org.apache.xml.internal.serializer.dom3.LSSerializerImpl}. */ +@Deprecated public interface DOMSerializer { --- old/src/java.xml/share/classes/com/sun/org/apache/xml/internal/serialize/DOMSerializerImpl.java 2017-06-14 09:39:02.872610513 -0700 +++ new/src/java.xml/share/classes/com/sun/org/apache/xml/internal/serialize/DOMSerializerImpl.java 2017-06-14 09:39:01.880560947 -0700 @@ -1,6 +1,5 @@ /* - * reserved comment block - * DO NOT REMOVE OR ALTER! + * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. */ /* * Licensed to the Apache Software Foundation (ASF) under one or more @@ -76,6 +75,7 @@ * @deprecated As of JDK 9, Xerces 2.9.0, replaced by * {@link com.sun.org.apache.xml.internal.serializer.dom3.LSSerializerImpl} */ +@Deprecated public class DOMSerializerImpl implements LSSerializer, DOMConfiguration { // TODO: When DOM Level 3 goes to REC replace method calls using --- old/src/java.xml/share/classes/com/sun/org/apache/xml/internal/serialize/ElementState.java 2017-06-14 09:39:26.877809831 -0700 +++ new/src/java.xml/share/classes/com/sun/org/apache/xml/internal/serialize/ElementState.java 2017-06-14 09:39:25.881760068 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2017 Oracle and/or its affiliates. All rights reserved. */ /* * Licensed to the Apache Software Foundation (ASF) under one or more @@ -36,6 +36,7 @@ * {@link com.sun.org.apache.xml.internal.serialize.DOMSerializerImpl} is replaced * by {@link com.sun.org.apache.xml.internal.serializer.dom3.LSSerializerImpl}. */ +@Deprecated public class ElementState { --- old/src/java.xml/share/classes/com/sun/org/apache/xml/internal/serialize/EncodingInfo.java 2017-06-14 09:39:57.195324454 -0700 +++ new/src/java.xml/share/classes/com/sun/org/apache/xml/internal/serialize/EncodingInfo.java 2017-06-14 09:39:55.039216802 -0700 @@ -1,6 +1,5 @@ /* - * reserved comment block - * DO NOT REMOVE OR ALTER! + * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. */ /* * Licensed to the Apache Software Foundation (ASF) under one or more @@ -37,6 +36,7 @@ * {@link com.sun.org.apache.xml.internal.serialize.DOMSerializerImpl} is replaced * by {@link com.sun.org.apache.xml.internal.serializer.dom3.LSSerializerImpl}. */ +@Deprecated public class EncodingInfo { // name of encoding as registered with IANA; --- old/src/java.xml/share/classes/com/sun/org/apache/xml/internal/serialize/Encodings.java 2017-06-14 09:40:20.956511604 -0700 +++ new/src/java.xml/share/classes/com/sun/org/apache/xml/internal/serialize/Encodings.java 2017-06-14 09:40:19.940460840 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2017 Oracle and/or its affiliates. All rights reserved. */ /* * Licensed to the Apache Software Foundation (ASF) under one or more @@ -42,6 +42,7 @@ * {@link com.sun.org.apache.xml.internal.serialize.DOMSerializerImpl} is replaced * by {@link com.sun.org.apache.xml.internal.serializer.dom3.LSSerializerImpl}. */ +@Deprecated class Encodings { --- old/src/java.xml/share/classes/com/sun/org/apache/xml/internal/serialize/HTMLSerializer.java 2017-06-14 09:40:44.521688902 -0700 +++ new/src/java.xml/share/classes/com/sun/org/apache/xml/internal/serialize/HTMLSerializer.java 2017-06-14 09:40:43.541639940 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2017 Oracle and/or its affiliates. All rights reserved. */ /* * Licensed to the Apache Software Foundation (ASF) under one or more @@ -92,6 +92,7 @@ * @author Assaf Arkin * @see Serializer */ +@Deprecated public class HTMLSerializer extends BaseMarkupSerializer { --- old/src/java.xml/share/classes/com/sun/org/apache/xml/internal/serialize/HTMLdtd.java 2017-06-14 09:41:08.326878180 -0700 +++ new/src/java.xml/share/classes/com/sun/org/apache/xml/internal/serialize/HTMLdtd.java 2017-06-14 09:41:07.262825023 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2017 Oracle and/or its affiliates. All rights reserved. */ /* * Licensed to the Apache Software Foundation (ASF) under one or more @@ -51,6 +51,7 @@ * {@link com.sun.org.apache.xml.internal.serialize.DOMSerializerImpl} is replaced * by {@link com.sun.org.apache.xml.internal.serializer.dom3.LSSerializerImpl}. */ +@Deprecated public final class HTMLdtd { --- old/src/java.xml/share/classes/com/sun/org/apache/xml/internal/serialize/IndentPrinter.java 2017-06-14 09:41:31.428032275 -0700 +++ new/src/java.xml/share/classes/com/sun/org/apache/xml/internal/serialize/IndentPrinter.java 2017-06-14 09:41:30.207971327 -0700 @@ -1,6 +1,5 @@ /* - * reserved comment block - * DO NOT REMOVE OR ALTER! + * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. */ /* * Licensed to the Apache Software Foundation (ASF) under one or more @@ -39,6 +38,7 @@ * {@link com.sun.org.apache.xml.internal.serialize.DOMSerializerImpl} is replaced * by {@link com.sun.org.apache.xml.internal.serializer.dom3.LSSerializerImpl}. */ +@Deprecated public class IndentPrinter extends Printer { --- old/src/java.xml/share/classes/com/sun/org/apache/xml/internal/serialize/LineSeparator.java 2017-06-14 09:41:54.649192359 -0700 +++ new/src/java.xml/share/classes/com/sun/org/apache/xml/internal/serialize/LineSeparator.java 2017-06-14 09:41:53.741146995 -0700 @@ -1,6 +1,5 @@ /* - * reserved comment block - * DO NOT REMOVE OR ALTER! + * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. */ /* * Licensed to the Apache Software Foundation (ASF) under one or more @@ -32,6 +31,7 @@ * {@link com.sun.org.apache.xml.internal.serialize.DOMSerializerImpl} is replaced * by {@link com.sun.org.apache.xml.internal.serializer.dom3.LSSerializerImpl}. */ +@Deprecated public final class LineSeparator { --- old/src/java.xml/share/classes/com/sun/org/apache/xml/internal/serialize/Method.java 2017-06-14 09:42:20.102463939 -0700 +++ new/src/java.xml/share/classes/com/sun/org/apache/xml/internal/serialize/Method.java 2017-06-14 09:42:19.102413981 -0700 @@ -1,6 +1,5 @@ /* - * reserved comment block - * DO NOT REMOVE OR ALTER! + * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. */ /* * Licensed to the Apache Software Foundation (ASF) under one or more @@ -32,6 +31,7 @@ * {@link com.sun.org.apache.xml.internal.serialize.DOMSerializerImpl} is replaced * by {@link com.sun.org.apache.xml.internal.serializer.dom3.LSSerializerImpl}. */ +@Deprecated public final class Method { --- old/src/java.xml/share/classes/com/sun/org/apache/xml/internal/serialize/OutputFormat.java 2017-06-14 09:42:47.063810850 -0700 +++ new/src/java.xml/share/classes/com/sun/org/apache/xml/internal/serialize/OutputFormat.java 2017-06-14 09:42:46.139764684 -0700 @@ -1,6 +1,5 @@ /* - * reserved comment block - * DO NOT REMOVE OR ALTER! + * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. */ /* * Licensed to the Apache Software Foundation (ASF) under one or more @@ -65,6 +64,7 @@ * {@link com.sun.org.apache.xml.internal.serialize.DOMSerializerImpl} is replaced * by {@link com.sun.org.apache.xml.internal.serializer.dom3.LSSerializerImpl}. */ +@Deprecated public class OutputFormat { --- old/src/java.xml/share/classes/com/sun/org/apache/xml/internal/serialize/Printer.java 2017-06-14 09:43:10.496981489 -0700 +++ new/src/java.xml/share/classes/com/sun/org/apache/xml/internal/serialize/Printer.java 2017-06-14 09:43:09.468930129 -0700 @@ -1,6 +1,5 @@ /* - * reserved comment block - * DO NOT REMOVE OR ALTER! + * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. */ /* * Licensed to the Apache Software Foundation (ASF) under one or more @@ -47,6 +46,7 @@ * {@link com.sun.org.apache.xml.internal.serialize.DOMSerializerImpl} is replaced * by {@link com.sun.org.apache.xml.internal.serializer.dom3.LSSerializerImpl}. */ +@Deprecated public class Printer { --- old/src/java.xml/share/classes/com/sun/org/apache/xml/internal/serialize/Serializer.java 2017-06-14 09:43:34.934202275 -0700 +++ new/src/java.xml/share/classes/com/sun/org/apache/xml/internal/serialize/Serializer.java 2017-06-14 09:43:33.942152718 -0700 @@ -1,6 +1,5 @@ /* - * reserved comment block - * DO NOT REMOVE OR ALTER! + * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. */ /* * Licensed to the Apache Software Foundation (ASF) under one or more @@ -67,6 +66,7 @@ * {@link com.sun.org.apache.xml.internal.serialize.DOMSerializerImpl} is replaced * by {@link com.sun.org.apache.xml.internal.serializer.dom3.LSSerializerImpl}. */ +@Deprecated public interface Serializer { --- old/src/java.xml/share/classes/com/sun/org/apache/xml/internal/serialize/SerializerFactory.java 2017-06-14 09:43:57.099309546 -0700 +++ new/src/java.xml/share/classes/com/sun/org/apache/xml/internal/serialize/SerializerFactory.java 2017-06-14 09:43:56.179263588 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2017 Oracle and/or its affiliates. All rights reserved. */ /* * Licensed to the Apache Software Foundation (ASF) under one or more @@ -42,6 +42,7 @@ * {@link com.sun.org.apache.xml.internal.serialize.DOMSerializerImpl} is replaced * by {@link com.sun.org.apache.xml.internal.serializer.dom3.LSSerializerImpl}. */ +@Deprecated public abstract class SerializerFactory { --- old/src/java.xml/share/classes/com/sun/org/apache/xml/internal/serialize/SerializerFactoryImpl.java 2017-06-14 09:44:20.636485354 -0700 +++ new/src/java.xml/share/classes/com/sun/org/apache/xml/internal/serialize/SerializerFactoryImpl.java 2017-06-14 09:44:19.660436599 -0700 @@ -1,6 +1,5 @@ /* - * reserved comment block - * DO NOT REMOVE OR ALTER! + * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. */ /* * Licensed to the Apache Software Foundation (ASF) under one or more @@ -41,6 +40,7 @@ * {@link com.sun.org.apache.xml.internal.serialize.DOMSerializerImpl} is replaced * by {@link com.sun.org.apache.xml.internal.serializer.dom3.LSSerializerImpl}. */ +@Deprecated final class SerializerFactoryImpl extends SerializerFactory { --- old/src/java.xml/share/classes/com/sun/org/apache/xml/internal/serialize/TextSerializer.java 2017-06-14 09:44:44.121658554 -0700 +++ new/src/java.xml/share/classes/com/sun/org/apache/xml/internal/serialize/TextSerializer.java 2017-06-14 09:44:43.133609196 -0700 @@ -1,6 +1,5 @@ /* - * reserved comment block - * DO NOT REMOVE OR ALTER! + * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. */ /* * Licensed to the Apache Software Foundation (ASF) under one or more @@ -65,6 +64,7 @@ * {@link com.sun.org.apache.xml.internal.serialize.DOMSerializerImpl} is replaced * by {@link com.sun.org.apache.xml.internal.serializer.dom3.LSSerializerImpl}. */ +@Deprecated public class TextSerializer extends BaseMarkupSerializer { --- old/src/java.xml/share/classes/com/sun/org/apache/xml/internal/serialize/XHTMLSerializer.java 2017-06-14 09:45:07.678835339 -0700 +++ new/src/java.xml/share/classes/com/sun/org/apache/xml/internal/serialize/XHTMLSerializer.java 2017-06-14 09:45:06.670784983 -0700 @@ -1,6 +1,5 @@ /* - * reserved comment block - * DO NOT REMOVE OR ALTER! + * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. */ /* * Licensed to the Apache Software Foundation (ASF) under one or more @@ -39,6 +38,7 @@ * @author Assaf Arkin * @see Serializer */ +@Deprecated public class XHTMLSerializer extends HTMLSerializer { --- old/src/java.xml/share/classes/com/sun/org/apache/xml/internal/serialize/XML11Serializer.java 2017-06-14 09:45:31.916046083 -0700 +++ new/src/java.xml/share/classes/com/sun/org/apache/xml/internal/serialize/XML11Serializer.java 2017-06-14 09:45:30.867993729 -0700 @@ -1,6 +1,5 @@ /* - * reserved comment block - * DO NOT REMOVE OR ALTER! + * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. */ /* * Licensed to the Apache Software Foundation (ASF) under one or more @@ -84,6 +83,7 @@ * {@link com.sun.org.apache.xml.internal.serialize.DOMSerializerImpl} is replaced * by {@link com.sun.org.apache.xml.internal.serializer.dom3.LSSerializerImpl}. */ +@Deprecated public class XML11Serializer extends XMLSerializer { --- old/src/java.xml/share/classes/com/sun/org/apache/xml/internal/serialize/XMLSerializer.java 2017-06-14 09:45:56.497274004 -0700 +++ new/src/java.xml/share/classes/com/sun/org/apache/xml/internal/serialize/XMLSerializer.java 2017-06-14 09:45:55.485223442 -0700 @@ -1,6 +1,5 @@ /* - * reserved comment block - * DO NOT REMOVE OR ALTER! + * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. */ /* * Licensed to the Apache Software Foundation (ASF) under one or more @@ -95,6 +94,7 @@ * {@link com.sun.org.apache.xml.internal.serialize.DOMSerializerImpl} is replaced * by {@link com.sun.org.apache.xml.internal.serializer.dom3.LSSerializerImpl}. */ +@Deprecated public class XMLSerializer extends BaseMarkupSerializer { --- old/src/java.xml/share/classes/com/sun/org/apache/xml/internal/serializer/TreeWalker.java 2017-06-14 09:46:20.778486926 -0700 +++ new/src/java.xml/share/classes/com/sun/org/apache/xml/internal/serializer/TreeWalker.java 2017-06-14 09:46:19.822439168 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved. */ /* * Licensed to the Apache Software Foundation (ASF) under one or more @@ -17,13 +17,12 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.sun.org.apache.xml.internal.serializer; -import com.sun.org.apache.xalan.internal.utils.SecuritySupport; -import java.io.File; +package com.sun.org.apache.xml.internal.serializer; -import com.sun.org.apache.xml.internal.serializer.utils.AttList; -import com.sun.org.apache.xml.internal.serializer.utils.DOM2Helper; +import com.sun.org.apache.xml.internal.utils.AttList; +import com.sun.org.apache.xml.internal.utils.DOM2Helper; +import javax.xml.transform.Result; import org.w3c.dom.Comment; import org.w3c.dom.Element; import org.w3c.dom.EntityReference; @@ -31,7 +30,6 @@ import org.w3c.dom.Node; import org.w3c.dom.ProcessingInstruction; import org.w3c.dom.Text; - import org.xml.sax.ContentHandler; import org.xml.sax.Locator; import org.xml.sax.ext.LexicalHandler; @@ -58,12 +56,6 @@ */ final private SerializationHandler m_Serializer; - // ARGHH!! JAXP Uses Xerces without setting the namespace processing to ON! - // DOM2Helper m_dh = new DOM2Helper(); - - /** DomHelper for this TreeWalker */ - final protected DOM2Helper m_dh; - /** Locator object for this TreeWalker */ final private LocatorImpl m_locator = new LocatorImpl(); @@ -78,7 +70,7 @@ } public TreeWalker(ContentHandler ch) { - this(ch,null); + this(ch, null); } /** * Constructor. @@ -99,8 +91,6 @@ if (systemId != null) { m_locator.setSystemId(systemId); } - - m_dh = new DOM2Helper(); } /** @@ -209,7 +199,7 @@ this.m_contentHandler.endDocument(); } - /** Flag indicating whether following text to be processed is raw text */ + // Flag indicating whether following text to be processed is raw text boolean nextIsRaw = false; /** @@ -313,7 +303,6 @@ final int colon = attrName.indexOf(':'); final String prefix; - // System.out.println("TreeWalker#startNode: attr["+i+"] = "+attrName+", "+attr.getNodeValue()); if (attrName.equals("xmlns") || attrName.startsWith("xmlns:")) { // Use "" instead of null, as Xerces likes "" for the @@ -335,13 +324,13 @@ } } - String ns = m_dh.getNamespaceOfNode(node); + String ns = DOM2Helper.getNamespaceOfNode(node); if(null == ns) ns = ""; this.m_contentHandler.startElement(ns, - m_dh.getLocalNameOfNode(node), + DOM2Helper.getLocalNameOfNode(node), node.getNodeName(), - new AttList(atts, m_dh)); + new AttList(atts)); break; case Node.PROCESSING_INSTRUCTION_NODE : { @@ -389,9 +378,9 @@ { nextIsRaw = false; - m_contentHandler.processingInstruction(javax.xml.transform.Result.PI_DISABLE_OUTPUT_ESCAPING, ""); + m_contentHandler.processingInstruction(Result.PI_DISABLE_OUTPUT_ESCAPING, ""); dispatachChars(node); - m_contentHandler.processingInstruction(javax.xml.transform.Result.PI_ENABLE_OUTPUT_ESCAPING, ""); + m_contentHandler.processingInstruction(Result.PI_ENABLE_OUTPUT_ESCAPING, ""); } else { @@ -436,12 +425,12 @@ break; case Node.ELEMENT_NODE : - String ns = m_dh.getNamespaceOfNode(node); + String ns = DOM2Helper.getNamespaceOfNode(node); if(null == ns) ns = ""; this.m_contentHandler.endElement(ns, - m_dh.getLocalNameOfNode(node), - node.getNodeName()); + DOM2Helper.getLocalNameOfNode(node), + node.getNodeName()); if (m_Serializer == null) { // Don't bother with endPrefixMapping calls if the ContentHandler is a --- old/src/java.xml/share/classes/com/sun/org/apache/xml/internal/utils/AttList.java 2017-06-14 09:46:44.187656277 -0700 +++ new/src/java.xml/share/classes/com/sun/org/apache/xml/internal/utils/AttList.java 2017-06-14 09:46:43.179605925 -0700 @@ -1,6 +1,5 @@ /* - * reserved comment block - * DO NOT REMOVE OR ALTER! + * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. */ /* * Licensed to the Apache Software Foundation (ASF) under one or more @@ -40,26 +39,9 @@ /** Index of last attribute node */ int m_lastIndex; - // ARGHH!! JAXP Uses Xerces without setting the namespace processing to ON! + // JAXP Uses Xerces without setting the namespace processing to ON! // DOM2Helper m_dh = new DOM2Helper(); - /** Local reference to DOMHelper */ - DOMHelper m_dh; - -// /** -// * Constructor AttList -// * -// * -// * @param attrs List of attributes this will contain -// */ -// public AttList(NamedNodeMap attrs) -// { -// -// m_attrs = attrs; -// m_lastIndex = m_attrs.getLength() - 1; -// m_dh = new DOM2Helper(); -// } - /** * Constructor AttList * @@ -67,12 +49,10 @@ * @param attrs List of attributes this will contain * @param dh DOMHelper */ - public AttList(NamedNodeMap attrs, DOMHelper dh) + public AttList(NamedNodeMap attrs) { - m_attrs = attrs; m_lastIndex = m_attrs.getLength() - 1; - m_dh = dh; } /** @@ -96,7 +76,7 @@ */ public String getURI(int index) { - String ns = m_dh.getNamespaceOfNode(((Attr) m_attrs.item(index))); + String ns = DOM2Helper.getNamespaceOfNode(((Attr) m_attrs.item(index))); if(null == ns) ns = ""; return ns; @@ -112,7 +92,7 @@ */ public String getLocalName(int index) { - return m_dh.getLocalNameOfNode(((Attr) m_attrs.item(index))); + return DOM2Helper.getLocalNameOfNode(((Attr) m_attrs.item(index))); } /** --- old/src/java.xml/share/classes/com/sun/org/apache/xml/internal/utils/DOM2Helper.java 2017-06-14 09:47:08.116851595 -0700 +++ new/src/java.xml/share/classes/com/sun/org/apache/xml/internal/utils/DOM2Helper.java 2017-06-14 09:47:07.088800244 -0700 @@ -1,6 +1,5 @@ /* - * reserved comment block - * DO NOT REMOVE OR ALTER! + * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. */ /* * Licensed to the Apache Software Foundation (ASF) under one or more @@ -18,298 +17,327 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package com.sun.org.apache.xml.internal.utils; -import java.io.IOException; - -import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.DocumentBuilderFactory; -import javax.xml.parsers.ParserConfigurationException; -import javax.xml.transform.TransformerException; - +import com.sun.org.apache.xml.internal.dtm.ref.DTMNodeProxy; import org.w3c.dom.Attr; -import org.w3c.dom.Document; -import org.w3c.dom.Element; +import org.w3c.dom.NamedNodeMap; import org.w3c.dom.Node; -import org.xml.sax.InputSource; /** - * @deprecated Since the introduction of the DTM, this class will be removed. - * This class provides a DOM level 2 "helper", which provides services currently - * not provided be the DOM standard. + * This class provides a DOM level 2 "helper", which provides several services. + * + * The original class extended DOMHelper that was deprecated and then removed. */ -public class DOM2Helper extends DOMHelper -{ +public final class DOM2Helper { - /** - * Construct an instance. - */ - public DOM2Helper(){} - - /** - * Check node to see if it was created by a DOM implementation - * that this helper is intended to support. This is currently - * disabled, and assumes all nodes are acceptable rather than checking - * that they implement com.sun.org.apache.xerces.internal.dom.NodeImpl. - * - * @param node The node to be tested. - * - * @throws TransformerException if the node is not one which this - * DOM2Helper can support. If we return without throwing the exception, - * the node is compatable. - * @xsl.usage internal - */ - public void checkNode(Node node) throws TransformerException - { - - // if(!(node instanceof com.sun.org.apache.xerces.internal.dom.NodeImpl)) - // throw new TransformerException(XSLMessages.createXPATHMessage(XPATHErrorResources.ER_XERCES_CANNOT_HANDLE_NODES, new Object[]{((Object)node).getClass()})); //"DOM2Helper can not handle nodes of type" - //+((Object)node).getClass()); - } - - /** - * Returns true if the DOM implementation handled by this helper - * supports the SAX ContentHandler interface. - * - * @return true (since Xerces does). - */ - public boolean supportsSAX() - { - return true; - } - - /** Field m_doc: Document Node for the document this helper is currently - * accessing or building - * @see #setDocument - * @see #getDocument - * */ - private Document m_doc; - - /** - * Specify which document this helper is currently operating on. - * - * @param doc The DOM Document node for this document. - * @see #getDocument - */ - public void setDocument(Document doc) - { - m_doc = doc; - } - - /** - * Query which document this helper is currently operating on. - * - * @return The DOM Document node for this document. - * @see #setDocument - */ - public Document getDocument() - { - return m_doc; - } - - /** - * Parse an XML document. - * - *

Right now the Xerces DOMParser class is used. This needs - * fixing, either via jaxp, or via some other, standard method.

- * - *

The application can use this method to instruct the SAX parser - * to begin parsing an XML document from any valid input - * source (a character stream, a byte stream, or a URI).

- * - *

Applications may not invoke this method while a parse is in - * progress (they should create a new Parser instead for each - * additional XML document). Once a parse is complete, an - * application may reuse the same Parser object, possibly with a - * different input source.

- * - * @param source The input source for the top-level of the - * XML document. - * - * @throws TransformerException if any checked exception is thrown. - * @xsl.usage internal - */ - public void parse(InputSource source) throws TransformerException - { - - try - { - - // I guess I should use JAXP factory here... when it's legal. - // com.sun.org.apache.xerces.internal.parsers.DOMParser parser - // = new com.sun.org.apache.xerces.internal.parsers.DOMParser(); - DocumentBuilderFactory builderFactory = - DocumentBuilderFactory.newInstance(); - - builderFactory.setNamespaceAware(true); - builderFactory.setValidating(true); - - DocumentBuilder parser = builderFactory.newDocumentBuilder(); - - /* - // domParser.setFeature("http://apache.org/xml/features/dom/create-entity-ref-nodes", getShouldExpandEntityRefs()? false : true); - if(m_useDOM2getNamespaceURI) - { - parser.setFeature("http://apache.org/xml/features/dom/defer-node-expansion", true); - parser.setFeature("http://xml.org/sax/features/namespaces", true); - } - else - { - parser.setFeature("http://apache.org/xml/features/dom/defer-node-expansion", false); - } - - parser.setFeature("http://apache.org/xml/features/allow-java-encodings", true); - */ - - parser.setErrorHandler( - new com.sun.org.apache.xml.internal.utils.DefaultErrorHandler()); - - // if(null != m_entityResolver) - // { - // System.out.println("Setting the entity resolver."); - // parser.setEntityResolver(m_entityResolver); - // } - setDocument(parser.parse(source)); + /** + * Construct an instance. + */ + private DOM2Helper() { } - catch (org.xml.sax.SAXException se) - { - throw new TransformerException(se); - } - catch (ParserConfigurationException pce) - { - throw new TransformerException(pce); - } - catch (IOException ioe) - { - throw new TransformerException(ioe); + + /** + * Returns the local name of the given node, as defined by the XML + * Namespaces specification. This is prepared to handle documents built + * using DOM Level 1 methods by falling back upon explicitly parsing the + * node name. + * + * @param n Node to be examined + * + * @return String containing the local name, or null if the node was not + * assigned a Namespace. + */ + public static String getLocalNameOfNode(Node n) { + + String name = n.getLocalName(); + + return (null == name) ? getLocalNameOfNodeFallback(n) : name; } - // setDocument(((com.sun.org.apache.xerces.internal.parsers.DOMParser)parser).getDocument()); - } + /** + * Returns the local name of the given node. If the node's name begins with + * a namespace prefix, this is the part after the colon; otherwise it's the + * full node name. + * + * This method is copied from + * com.sun.org.apache.xml.internal.utils.DOMHelper + * + * @param n the node to be examined. + * + * @return String containing the Local Name + */ + private static String getLocalNameOfNodeFallback(Node n) { - /** - * Given an XML ID, return the element. This requires assistance from the - * DOM and parser, and is meaningful only in the context of a DTD - * or schema which declares attributes as being of type ID. This - * information may or may not be available in all parsers, may or - * may not be available for specific documents, and may or may not - * be available when validation is not turned on. - * - * @param id The ID to search for, as a String. - * @param doc The document to search within, as a DOM Document node. - * @return DOM Element node with an attribute of type ID whose value - * uniquely matches the requested id string, or null if there isn't - * such an element or if the DOM can't answer the question for other - * reasons. - */ - public Element getElementByID(String id, Document doc) - { - return doc.getElementById(id); - } - - /** - * Figure out whether node2 should be considered as being later - * in the document than node1, in Document Order as defined - * by the XPath model. This may not agree with the ordering defined - * by other XML applications. - *

- * There are some cases where ordering isn't defined, and neither are - * the results of this function -- though we'll generally return true. - *

- * TODO: Make sure this does the right thing with attribute nodes!!! - * - * @param node1 DOM Node to perform position comparison on. - * @param node2 DOM Node to perform position comparison on . - * - * @return false if node2 comes before node1, otherwise return true. - * You can think of this as - * (node1.documentOrderPosition <= node2.documentOrderPosition). - */ - public static boolean isNodeAfter(Node node1, Node node2) - { - - // Assume first that the nodes are DTM nodes, since discovering node - // order is massivly faster for the DTM. - if(node1 instanceof DOMOrder && node2 instanceof DOMOrder) - { - int index1 = ((DOMOrder) node1).getUid(); - int index2 = ((DOMOrder) node2).getUid(); + String qname = n.getNodeName(); + int index = qname.indexOf(':'); + + return (index < 0) ? qname : qname.substring(index + 1); + } - return index1 <= index2; + /** + * Returns the Namespace Name (Namespace URI) for the given node. In a Level + * 2 DOM, you can ask the node itself. Note, however, that doing so + * conflicts with our decision in getLocalNameOfNode not to trust the that + * the DOM was indeed created using the Level 2 methods. If Level 1 methods + * were used, these two functions will disagree with each other. + *

+ * TODO: Reconcile with getLocalNameOfNode. + * + * @param n Node to be examined + * + * @return String containing the Namespace URI bound to this DOM node at the + * time the Node was created. + */ + public static String getNamespaceOfNode(Node n) { + return n.getNamespaceURI(); } - else - { - // isNodeAfter will return true if node is after countedNode - // in document order. The base isNodeAfter is sloooow (relatively). - return DOMHelper.isNodeAfter(node1, node2); + /** + * Figure out whether node2 should be considered as being later in the + * document than node1, in Document Order as defined by the XPath model. + * This may not agree with the ordering defined by other XML applications. + *

+ * There are some cases where ordering isn't defined, and neither are the + * results of this function -- though we'll generally return true. + * + * @param node1 DOM Node to perform position comparison on. + * @param node2 DOM Node to perform position comparison on . + * + * @return false if node2 comes before node1, otherwise return true. You can + * think of this as + * {@code (node1.documentOrderPosition <= node2.documentOrderPosition)}. + */ + public static boolean isNodeAfter(Node node1, Node node2) { + if (node1 == node2 || isNodeTheSame(node1, node2)) { + return true; + } + + // Default return value, if there is no defined ordering + boolean isNodeAfter = true; + + Node parent1 = getParentOfNode(node1); + Node parent2 = getParentOfNode(node2); + + // Optimize for most common case + if (parent1 == parent2 || isNodeTheSame(parent1, parent2)) // then we know they are siblings + { + if (null != parent1) { + isNodeAfter = isNodeAfterSibling(parent1, node1, node2); + } + } else { + // General strategy: Figure out the lengths of the two + // ancestor chains, reconcile the lengths, and look for + // the lowest common ancestor. If that ancestor is one of + // the nodes being compared, it comes before the other. + // Otherwise perform a sibling compare. + // + // NOTE: If no common ancestor is found, ordering is undefined + // and we return the default value of isNodeAfter. + // Count parents in each ancestor chain + int nParents1 = 2, nParents2 = 2; // include node & parent obtained above + + while (parent1 != null) { + nParents1++; + + parent1 = getParentOfNode(parent1); + } + + while (parent2 != null) { + nParents2++; + + parent2 = getParentOfNode(parent2); + } + + // Initially assume scan for common ancestor starts with + // the input nodes. + Node startNode1 = node1, startNode2 = node2; + + // If one ancestor chain is longer, adjust its start point + // so we're comparing at the same depths + if (nParents1 < nParents2) { + // Adjust startNode2 to depth of startNode1 + int adjust = nParents2 - nParents1; + + for (int i = 0; i < adjust; i++) { + startNode2 = getParentOfNode(startNode2); + } + } else if (nParents1 > nParents2) { + // adjust startNode1 to depth of startNode2 + int adjust = nParents1 - nParents2; + + for (int i = 0; i < adjust; i++) { + startNode1 = getParentOfNode(startNode1); + } + } + + Node prevChild1 = null, prevChild2 = null; // so we can "back up" + + // Loop up the ancestor chain looking for common parent + while (null != startNode1) { + if (startNode1 == startNode2 || isNodeTheSame(startNode1, startNode2)) // common parent? + { + if (null == prevChild1) // first time in loop? + { + + // Edge condition: one is the ancestor of the other. + isNodeAfter = (nParents1 < nParents2) ? true : false; + + break; // from while loop + } else { + // Compare ancestors below lowest-common as siblings + isNodeAfter = isNodeAfterSibling(startNode1, prevChild1, + prevChild2); + + break; // from while loop + } + } // end if(startNode1 == startNode2) + + // Move up one level and try again + prevChild1 = startNode1; + startNode1 = getParentOfNode(startNode1); + prevChild2 = startNode2; + startNode2 = getParentOfNode(startNode2); + } // end while(parents exist to examine) + } // end big else (not immediate siblings) + + return isNodeAfter; + } // end isNodeAfter(Node node1, Node node2) + + /** + * Use DTMNodeProxy to determine whether two nodes are the same. + * + * @param node1 The first DOM node to compare. + * @param node2 The second DOM node to compare. + * @return true if the two nodes are the same. + */ + public static boolean isNodeTheSame(Node node1, Node node2) { + if (node1 instanceof DTMNodeProxy && node2 instanceof DTMNodeProxy) { + return ((DTMNodeProxy) node1).equals((DTMNodeProxy) node2); + } else { + return (node1 == node2); + } } - } - /** - * Get the XPath-model parent of a node. This version takes advantage - * of the DOM Level 2 Attr.ownerElement() method; the base version we - * would otherwise inherit is prepared to fall back on exhaustively - * walking the document to find an Attr's parent. - * - * @param node Node to be examined - * - * @return the DOM parent of the input node, if there is one, or the - * ownerElement if the input node is an Attr, or null if the node is - * a Document, a DocumentFragment, or an orphan. - */ - public static Node getParentOfNode(Node node) - { - Node parent=node.getParentNode(); - if(parent==null && (Node.ATTRIBUTE_NODE == node.getNodeType()) ) - parent=((Attr) node).getOwnerElement(); - return parent; - } - - /** - * Returns the local name of the given node, as defined by the - * XML Namespaces specification. This is prepared to handle documents - * built using DOM Level 1 methods by falling back upon explicitly - * parsing the node name. - * - * @param n Node to be examined - * - * @return String containing the local name, or null if the node - * was not assigned a Namespace. - */ - public String getLocalNameOfNode(Node n) - { - - String name = n.getLocalName(); - - return (null == name) ? super.getLocalNameOfNode(n) : name; - } - - /** - * Returns the Namespace Name (Namespace URI) for the given node. - * In a Level 2 DOM, you can ask the node itself. Note, however, that - * doing so conflicts with our decision in getLocalNameOfNode not - * to trust the that the DOM was indeed created using the Level 2 - * methods. If Level 1 methods were used, these two functions will - * disagree with each other. - *

- * TODO: Reconcile with getLocalNameOfNode. - * - * @param n Node to be examined - * - * @return String containing the Namespace URI bound to this DOM node - * at the time the Node was created. - */ - public String getNamespaceOfNode(Node n) - { - return n.getNamespaceURI(); - } - - /** Field m_useDOM2getNamespaceURI is a compile-time flag which - * gates some of the parser options used to build a DOM -- but - * that code is commented out at this time and nobody else - * references it, so I've commented this out as well. */ - //private boolean m_useDOM2getNamespaceURI = false; + /** + * Get the XPath-model parent of a node. This version takes advantage of the + * DOM Level 2 Attr.ownerElement() method; the base version we would + * otherwise inherit is prepared to fall back on exhaustively walking the + * document to find an Attr's parent. + * + * @param node Node to be examined + * + * @return the DOM parent of the input node, if there is one, or the + * ownerElement if the input node is an Attr, or null if the node is a + * Document, a DocumentFragment, or an orphan. + */ + public static Node getParentOfNode(Node node) { + Node parent = node.getParentNode(); + if (parent == null && (Node.ATTRIBUTE_NODE == node.getNodeType())) { + parent = ((Attr) node).getOwnerElement(); + } + return parent; + } + + /** + * Figure out if child2 is after child1 in document order. + *

+ * Warning: Some aspects of "document order" are not well defined. For + * example, the order of attributes is considered meaningless in XML, and + * the order reported by our model will be consistent for a given invocation + * but may not match that of either the source file or the serialized + * output. + * + * @param parent Must be the parent of both child1 and child2. + * @param child1 Must be the child of parent and not equal to child2. + * @param child2 Must be the child of parent and not equal to child1. + * @return true if child 2 is after child1 in document order. + */ + private static boolean isNodeAfterSibling(Node parent, Node child1, + Node child2) { + + boolean isNodeAfterSibling = false; + short child1type = child1.getNodeType(); + short child2type = child2.getNodeType(); + + if ((Node.ATTRIBUTE_NODE != child1type) + && (Node.ATTRIBUTE_NODE == child2type)) { + + // always sort attributes before non-attributes. + isNodeAfterSibling = false; + } else if ((Node.ATTRIBUTE_NODE == child1type) + && (Node.ATTRIBUTE_NODE != child2type)) { + + // always sort attributes before non-attributes. + isNodeAfterSibling = true; + } else if (Node.ATTRIBUTE_NODE == child1type) { + NamedNodeMap children = parent.getAttributes(); + int nNodes = children.getLength(); + boolean found1 = false, found2 = false; + + // Count from the start until we find one or the other. + for (int i = 0; i < nNodes; i++) { + Node child = children.item(i); + + if (child1 == child || isNodeTheSame(child1, child)) { + if (found2) { + isNodeAfterSibling = false; + + break; + } + + found1 = true; + } else if (child2 == child || isNodeTheSame(child2, child)) { + if (found1) { + isNodeAfterSibling = true; + + break; + } + + found2 = true; + } + } + } else { + // TODO: Check performance of alternate solution: + // There are two choices here: Count from the start of + // the document until we find one or the other, or count + // from one until we find or fail to find the other. + // Either can wind up scanning all the siblings in the worst + // case, which on a wide document can be a lot of work but + // is more typically is a short list. + // Scanning from the start involves two tests per iteration, + // but it isn't clear that scanning from the middle doesn't + // yield more iterations on average. + // We should run some testcases. + Node child = parent.getFirstChild(); + boolean found1 = false, found2 = false; + + while (null != child) { + + // Node child = children.item(i); + if (child1 == child || isNodeTheSame(child1, child)) { + if (found2) { + isNodeAfterSibling = false; + + break; + } + + found1 = true; + } else if (child2 == child || isNodeTheSame(child2, child)) { + if (found1) { + isNodeAfterSibling = true; + + break; + } + + found2 = true; + } + + child = child.getNextSibling(); + } + } + + return isNodeAfterSibling; + } // end isNodeAfterSibling(Node parent, Node child1, Node child2) } --- old/src/java.xml/share/classes/com/sun/org/apache/xml/internal/utils/TreeWalker.java 2017-06-14 09:47:31.562022728 -0700 +++ new/src/java.xml/share/classes/com/sun/org/apache/xml/internal/utils/TreeWalker.java 2017-06-14 09:47:30.989994154 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved. */ /* * Licensed to the Apache Software Foundation (ASF) under one or more @@ -17,11 +17,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.sun.org.apache.xml.internal.utils; -import com.sun.org.apache.xalan.internal.utils.SecuritySupport; -import java.io.File; +package com.sun.org.apache.xml.internal.utils; +import com.sun.org.apache.xml.internal.dtm.ref.dom2dtm.DOM2DTM.CharacterNodeHandler; +import javax.xml.transform.Result; import org.w3c.dom.Comment; import org.w3c.dom.Element; import org.w3c.dom.EntityReference; @@ -47,14 +47,8 @@ /** Local reference to a ContentHandler */ private ContentHandler m_contentHandler = null; - // ARGHH!! JAXP Uses Xerces without setting the namespace processing to ON! - // DOM2Helper m_dh = new DOM2Helper(); - - /** DomHelper for this TreeWalker */ - protected DOMHelper m_dh; - - /** Locator object for this TreeWalker */ - private LocatorImpl m_locator = new LocatorImpl(); + /** Locator object for this TreeWalker */ + private LocatorImpl m_locator = new LocatorImpl(); /** * Get the ContentHandler used for the tree walk. @@ -76,32 +70,21 @@ m_contentHandler = ch; } - /** + /** * Constructor. * @param contentHandler The implementation of the * @param systemId System identifier for the document. * contentHandler operation (toXMLString, digest, ...) */ - public TreeWalker(ContentHandler contentHandler, DOMHelper dh, String systemId) + public TreeWalker(ContentHandler contentHandler, String systemId) { this.m_contentHandler = contentHandler; - m_contentHandler.setDocumentLocator(m_locator); + if (m_contentHandler != null) { + m_contentHandler.setDocumentLocator(m_locator); + } if (systemId != null) { m_locator.setSystemId(systemId); } - m_dh = dh; - } - - /** - * Constructor. - * @param contentHandler The implementation of the - * contentHandler operation (toXMLString, digest, ...) - */ - public TreeWalker(ContentHandler contentHandler, DOMHelper dh) - { - this.m_contentHandler = contentHandler; - m_contentHandler.setDocumentLocator(m_locator); - m_dh = dh; } /** @@ -111,11 +94,7 @@ */ public TreeWalker(ContentHandler contentHandler) { - this.m_contentHandler = contentHandler; - if (m_contentHandler != null) { - m_contentHandler.setDocumentLocator(m_locator); - } - m_dh = new DOM2Helper(); + this(contentHandler, null); } /** @@ -239,7 +218,7 @@ this.m_contentHandler.endDocument(); } - /** Flag indicating whether following text to be processed is raw text */ + // Flag indicating whether following text to be processed is raw text boolean nextIsRaw = false; /** @@ -248,9 +227,9 @@ private final void dispatachChars(Node node) throws org.xml.sax.SAXException { - if(m_contentHandler instanceof com.sun.org.apache.xml.internal.dtm.ref.dom2dtm.DOM2DTM.CharacterNodeHandler) + if(m_contentHandler instanceof CharacterNodeHandler) { - ((com.sun.org.apache.xml.internal.dtm.ref.dom2dtm.DOM2DTM.CharacterNodeHandler)m_contentHandler).characters(node); + ((CharacterNodeHandler)m_contentHandler).characters(node); } else { @@ -313,17 +292,14 @@ case Node.ELEMENT_NODE : NamedNodeMap atts = ((Element) node).getAttributes(); int nAttrs = atts.getLength(); - // System.out.println("TreeWalker#startNode: "+node.getNodeName()); for (int i = 0; i < nAttrs; i++) { Node attr = atts.item(i); String attrName = attr.getNodeName(); - // System.out.println("TreeWalker#startNode: attr["+i+"] = "+attrName+", "+attr.getNodeValue()); if (attrName.equals("xmlns") || attrName.startsWith("xmlns:")) { - // System.out.println("TreeWalker#startNode: attr["+i+"] = "+attrName+", "+attr.getNodeValue()); int index; // Use "" instead of null, as Xerces likes "" for the // name of the default namespace. Fix attributed @@ -337,15 +313,13 @@ } - // System.out.println("m_dh.getNamespaceOfNode(node): "+m_dh.getNamespaceOfNode(node)); - // System.out.println("m_dh.getLocalNameOfNode(node): "+m_dh.getLocalNameOfNode(node)); - String ns = m_dh.getNamespaceOfNode(node); + String ns = DOM2Helper.getNamespaceOfNode(node); if(null == ns) ns = ""; this.m_contentHandler.startElement(ns, - m_dh.getLocalNameOfNode(node), + DOM2Helper.getLocalNameOfNode(node), node.getNodeName(), - new AttList(atts, m_dh)); + new AttList(atts)); break; case Node.PROCESSING_INSTRUCTION_NODE : { @@ -393,9 +367,9 @@ { nextIsRaw = false; - m_contentHandler.processingInstruction(javax.xml.transform.Result.PI_DISABLE_OUTPUT_ESCAPING, ""); + m_contentHandler.processingInstruction(Result.PI_DISABLE_OUTPUT_ESCAPING, ""); dispatachChars(node); - m_contentHandler.processingInstruction(javax.xml.transform.Result.PI_ENABLE_OUTPUT_ESCAPING, ""); + m_contentHandler.processingInstruction(Result.PI_ENABLE_OUTPUT_ESCAPING, ""); } else { @@ -440,12 +414,12 @@ break; case Node.ELEMENT_NODE : - String ns = m_dh.getNamespaceOfNode(node); + String ns = DOM2Helper.getNamespaceOfNode(node); if(null == ns) ns = ""; this.m_contentHandler.endElement(ns, - m_dh.getLocalNameOfNode(node), - node.getNodeName()); + DOM2Helper.getLocalNameOfNode(node), + node.getNodeName()); NamedNodeMap atts = ((Element) node).getAttributes(); int nAttrs = atts.getLength(); --- old/src/java.xml/share/classes/com/sun/org/apache/xpath/internal/operations/Quo.java 2017-06-14 09:47:55.251206038 -0700 +++ new/src/java.xml/share/classes/com/sun/org/apache/xpath/internal/operations/Quo.java 2017-06-14 09:47:54.211154086 -0700 @@ -1,6 +1,5 @@ /* - * reserved comment block - * DO NOT REMOVE OR ALTER! + * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. */ /* * Licensed to the Apache Software Foundation (ASF) under one or more @@ -28,6 +27,7 @@ * The 'quo' operation expression executer. (no longer supported by XPath). * @deprecated */ +@Deprecated public class Quo extends Operation { static final long serialVersionUID = 693765299196169905L; --- old/src/java.xml/share/classes/org/xml/sax/HandlerBase.java 2017-06-14 09:48:18.704377548 -0700 +++ new/src/java.xml/share/classes/org/xml/sax/HandlerBase.java 2017-06-14 09:48:17.648324800 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2006, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -66,6 +66,7 @@ * @see org.xml.sax.DocumentHandler * @see org.xml.sax.ErrorHandler */ +@Deprecated(since="1.5") public class HandlerBase implements EntityResolver, DTDHandler, DocumentHandler, ErrorHandler { --- old/src/java.xml/share/classes/org/xml/sax/helpers/AttributeListImpl.java 2017-06-14 09:48:40.341458334 -0700 +++ new/src/java.xml/share/classes/org/xml/sax/helpers/AttributeListImpl.java 2017-06-14 09:48:39.229402789 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2005, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -87,6 +87,7 @@ * @see org.xml.sax.AttributeList * @see org.xml.sax.DocumentHandler#startElement */ +@Deprecated(since="1.5") public class AttributeListImpl implements AttributeList { --- old/src/java.xml/share/classes/com/sun/org/apache/xml/internal/serializer/utils/AttList.java 2017-06-14 09:49:03.642622237 -0700 +++ /dev/null 2017-01-27 21:23:58.368196991 -0800 @@ -1,264 +0,0 @@ -/* - * reserved comment block - * DO NOT REMOVE OR ALTER! - */ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.sun.org.apache.xml.internal.serializer.utils; - -import org.w3c.dom.Attr; -import org.w3c.dom.NamedNodeMap; -import org.w3c.dom.Node; - -import org.xml.sax.Attributes; - -/** - * Wraps a DOM attribute list in a SAX Attributes. - * - * This class is a copy of the one in com.sun.org.apache.xml.internal.utils. - * It exists to cut the serializers dependancy on that package. - * A minor changes from that package are: - * DOMHelper reference changed to DOM2Helper, class is not "public" - * - * This class is not a public API, it is only public because it is - * used in com.sun.org.apache.xml.internal.serializer. - * - * @xsl.usage internal - */ -public final class AttList implements Attributes -{ - - /** List of attribute nodes */ - NamedNodeMap m_attrs; - - /** Index of last attribute node */ - int m_lastIndex; - - // ARGHH!! JAXP Uses Xerces without setting the namespace processing to ON! - // DOM2Helper m_dh = new DOM2Helper(); - - /** Local reference to DOMHelper */ - DOM2Helper m_dh; - -// /** -// * Constructor AttList -// * -// * -// * @param attrs List of attributes this will contain -// */ -// public AttList(NamedNodeMap attrs) -// { -// -// m_attrs = attrs; -// m_lastIndex = m_attrs.getLength() - 1; -// m_dh = new DOM2Helper(); -// } - - /** - * Constructor AttList - * - * - * @param attrs List of attributes this will contain - * @param dh DOMHelper - */ - public AttList(NamedNodeMap attrs, DOM2Helper dh) - { - - m_attrs = attrs; - m_lastIndex = m_attrs.getLength() - 1; - m_dh = dh; - } - - /** - * Get the number of attribute nodes in the list - * - * - * @return number of attribute nodes - */ - public int getLength() - { - return m_attrs.getLength(); - } - - /** - * Look up an attribute's Namespace URI by index. - * - * @param index The attribute index (zero-based). - * @return The Namespace URI, or the empty string if none - * is available, or null if the index is out of - * range. - */ - public String getURI(int index) - { - String ns = m_dh.getNamespaceOfNode(((Attr) m_attrs.item(index))); - if(null == ns) - ns = ""; - return ns; - } - - /** - * Look up an attribute's local name by index. - * - * @param index The attribute index (zero-based). - * @return The local name, or the empty string if Namespace - * processing is not being performed, or null - * if the index is out of range. - */ - public String getLocalName(int index) - { - return m_dh.getLocalNameOfNode(((Attr) m_attrs.item(index))); - } - - /** - * Look up an attribute's qualified name by index. - * - * - * @param i The attribute index (zero-based). - * - * @return The attribute's qualified name - */ - public String getQName(int i) - { - return ((Attr) m_attrs.item(i)).getName(); - } - - /** - * Get the attribute's node type by index - * - * - * @param i The attribute index (zero-based) - * - * @return the attribute's node type - */ - public String getType(int i) - { - return "CDATA"; // for the moment - } - - /** - * Get the attribute's node value by index - * - * - * @param i The attribute index (zero-based) - * - * @return the attribute's node value - */ - public String getValue(int i) - { - return ((Attr) m_attrs.item(i)).getValue(); - } - - /** - * Get the attribute's node type by name - * - * - * @param name Attribute name - * - * @return the attribute's node type - */ - public String getType(String name) - { - return "CDATA"; // for the moment - } - - /** - * Look up an attribute's type by Namespace name. - * - * @param uri The Namespace URI, or the empty String if the - * name has no Namespace URI. - * @param localName The local name of the attribute. - * @return The attribute type as a string, or null if the - * attribute is not in the list or if Namespace - * processing is not being performed. - */ - public String getType(String uri, String localName) - { - return "CDATA"; // for the moment - } - - /** - * Look up an attribute's value by name. - * - * - * @param name The attribute node's name - * - * @return The attribute node's value - */ - public String getValue(String name) - { - Attr attr = ((Attr) m_attrs.getNamedItem(name)); - return (null != attr) - ? attr.getValue() : null; - } - - /** - * Look up an attribute's value by Namespace name. - * - * @param uri The Namespace URI, or the empty String if the - * name has no Namespace URI. - * @param localName The local name of the attribute. - * @return The attribute value as a string, or null if the - * attribute is not in the list. - */ - public String getValue(String uri, String localName) - { - Node a=m_attrs.getNamedItemNS(uri,localName); - return (a==null) ? null : a.getNodeValue(); - } - - /** - * Look up the index of an attribute by Namespace name. - * - * @param uri The Namespace URI, or the empty string if - * the name has no Namespace URI. - * @param localPart The attribute's local name. - * @return The index of the attribute, or -1 if it does not - * appear in the list. - */ - public int getIndex(String uri, String localPart) - { - for(int i=m_attrs.getLength()-1;i>=0;--i) - { - Node a=m_attrs.item(i); - String u=a.getNamespaceURI(); - if( (u==null ? uri==null : u.equals(uri)) - && - a.getLocalName().equals(localPart) ) - return i; - } - return -1; - } - - /** - * Look up the index of an attribute by raw XML 1.0 name. - * - * @param qName The qualified (prefixed) name. - * @return The index of the attribute, or -1 if it does not - * appear in the list. - */ - public int getIndex(String qName) - { - for(int i=m_attrs.getLength()-1;i>=0;--i) - { - Node a=m_attrs.item(i); - if(a.getNodeName().equals(qName) ) - return i; - } - return -1; - } -} --- old/src/java.xml/share/classes/com/sun/org/apache/xml/internal/serializer/utils/DOM2Helper.java 2017-06-14 09:49:16.275253240 -0700 +++ /dev/null 2017-01-27 21:23:58.368196991 -0800 @@ -1,135 +0,0 @@ -/* - * reserved comment block - * DO NOT REMOVE OR ALTER! - */ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.sun.org.apache.xml.internal.serializer.utils; - -import java.io.IOException; - -import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.DocumentBuilderFactory; -import javax.xml.parsers.ParserConfigurationException; -import javax.xml.transform.TransformerException; - -import org.w3c.dom.Attr; -import org.w3c.dom.Document; -import org.w3c.dom.Element; -import org.w3c.dom.Node; - -import org.xml.sax.InputSource; - -/** - * This class provides a DOM level 2 "helper", which provides services currently - * not provided be the DOM standard. - * - * This class is a copy of the one in com.sun.org.apache.xml.internal.utils. - * It exists to cut the serializers dependancy on that package. - * - * The differences from the original class are: - * it doesn't extend DOMHelper, not depricated, - * dropped method isNodeAfter(Node node1, Node node2) - * dropped method parse(InputSource) - * dropped method supportSAX() - * dropped method setDocument(doc) - * dropped method checkNode(Node) - * dropped method getDocument() - * dropped method getElementByID(String id, Document doc) - * dropped method getParentOfNode(Node node) - * dropped field Document m_doc; - * made class non-public - * - * This class is not a public API, it is only public because it is - * used in com.sun.org.apache.xml.internal.serializer. - * - * @xsl.usage internal - */ -public final class DOM2Helper -{ - - /** - * Construct an instance. - */ - public DOM2Helper(){} - - /** - * Returns the local name of the given node, as defined by the - * XML Namespaces specification. This is prepared to handle documents - * built using DOM Level 1 methods by falling back upon explicitly - * parsing the node name. - * - * @param n Node to be examined - * - * @return String containing the local name, or null if the node - * was not assigned a Namespace. - */ - public String getLocalNameOfNode(Node n) - { - - String name = n.getLocalName(); - - return (null == name) ? getLocalNameOfNodeFallback(n) : name; - } - - /** - * Returns the local name of the given node. If the node's name begins - * with a namespace prefix, this is the part after the colon; otherwise - * it's the full node name. - * - * This method is copied from com.sun.org.apache.xml.internal.utils.DOMHelper - * - * @param n the node to be examined. - * - * @return String containing the Local Name - */ - private String getLocalNameOfNodeFallback(Node n) - { - - String qname = n.getNodeName(); - int index = qname.indexOf(':'); - - return (index < 0) ? qname : qname.substring(index + 1); - } - - /** - * Returns the Namespace Name (Namespace URI) for the given node. - * In a Level 2 DOM, you can ask the node itself. Note, however, that - * doing so conflicts with our decision in getLocalNameOfNode not - * to trust the that the DOM was indeed created using the Level 2 - * methods. If Level 1 methods were used, these two functions will - * disagree with each other. - *

- * TODO: Reconcile with getLocalNameOfNode. - * - * @param n Node to be examined - * - * @return String containing the Namespace URI bound to this DOM node - * at the time the Node was created. - */ - public String getNamespaceOfNode(Node n) - { - return n.getNamespaceURI(); - } - - /** Field m_useDOM2getNamespaceURI is a compile-time flag which - * gates some of the parser options used to build a DOM -- but - * that code is commented out at this time and nobody else - * references it, so I've commented this out as well. */ - //private boolean m_useDOM2getNamespaceURI = false; -} --- old/src/java.xml/share/classes/com/sun/org/apache/xml/internal/utils/DOMHelper.java 2017-06-14 09:49:28.451861454 -0700 +++ /dev/null 2017-01-27 21:23:58.368196991 -0800 @@ -1,1330 +0,0 @@ -/* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. - */ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/* - * $Id: DOMHelper.java,v 1.2.4.1 2005/09/15 08:15:40 suresh_emailid Exp $ - */ -package com.sun.org.apache.xml.internal.utils; - -import com.sun.org.apache.xml.internal.dtm.ref.DTMNodeProxy; -import com.sun.org.apache.xml.internal.res.XMLErrorResources; -import com.sun.org.apache.xml.internal.res.XMLMessages; -import java.util.HashMap; -import java.util.Map; -import java.util.Vector; -import javax.xml.XMLConstants; -import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.DocumentBuilderFactory; -import javax.xml.parsers.ParserConfigurationException; -import org.w3c.dom.Attr; -import org.w3c.dom.DOMImplementation; -import org.w3c.dom.Document; -import org.w3c.dom.DocumentType; -import org.w3c.dom.Element; -import org.w3c.dom.Entity; -import org.w3c.dom.NamedNodeMap; -import org.w3c.dom.Node; -import org.w3c.dom.Text; - -/** - * @deprecated Since the introduction of the DTM, this class will be removed. - * This class provides a front-end to DOM implementations, providing - * a number of utility functions that either aren't yet standardized - * by the DOM spec or that are defined in optional DOM modules and - * hence may not be present in all DOMs. - */ -public class DOMHelper -{ - - /** - * DOM Level 1 did not have a standard mechanism for creating a new - * Document object. This function provides a DOM-implementation-independent - * abstraction for that for that concept. It's typically used when - * outputting a new DOM as the result of an operation. - *

- * TODO: This isn't directly compatable with DOM Level 2. - * The Level 2 createDocument call also creates the root - * element, and thus requires that you know what that element will be - * before creating the Document. We should think about whether we want - * to change this code, and the callers, so we can use the DOM's own - * method. (It's also possible that DOM Level 3 may relax this - * sequence, but you may give up some intelligence in the DOM by - * doing so; the intent was that knowing the document type and root - * element might let the DOM automatically switch to a specialized - * subclass for particular kinds of documents.) - * - * @param isSecureProcessing state of the secure processing feature. - * @return The newly created DOM Document object, with no children, or - * null if we can't find a DOM implementation that permits creating - * new empty Documents. - */ - public static Document createDocument(boolean isSecureProcessing) - { - - try - { - - // Use an implementation of the JAVA API for XML Parsing 1.0 to - // create a DOM Document node to contain the result. - DocumentBuilderFactory dfactory = DocumentBuilderFactory.newInstance(); - - dfactory.setNamespaceAware(true); - dfactory.setValidating(true); - - if (isSecureProcessing) - { - try - { - dfactory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true); - } - catch (ParserConfigurationException pce) {} - } - - DocumentBuilder docBuilder = dfactory.newDocumentBuilder(); - Document outNode = docBuilder.newDocument(); - - return outNode; - } - catch (ParserConfigurationException pce) - { - throw new RuntimeException( - XMLMessages.createXMLMessage( - XMLErrorResources.ER_CREATEDOCUMENT_NOT_SUPPORTED, null)); //"createDocument() not supported in XPathContext!"); - - // return null; - } - } - - /** - * DOM Level 1 did not have a standard mechanism for creating a new - * Document object. This function provides a DOM-implementation-independent - * abstraction for that for that concept. It's typically used when - * outputting a new DOM as the result of an operation. - * - * @return The newly created DOM Document object, with no children, or - * null if we can't find a DOM implementation that permits creating - * new empty Documents. - */ - public static Document createDocument() - { - return createDocument(false); - } - - /** - * Tells, through the combination of the default-space attribute - * on xsl:stylesheet, xsl:strip-space, xsl:preserve-space, and the - * xml:space attribute, whether or not extra whitespace should be stripped - * from the node. Literal elements from template elements should - * not be tested with this function. - * @param textNode A text node from the source tree. - * @return true if the text node should be stripped of extra whitespace. - * - * @throws javax.xml.transform.TransformerException - * @xsl.usage advanced - */ - public boolean shouldStripSourceNode(Node textNode) - throws javax.xml.transform.TransformerException - { - - // return (null == m_envSupport) ? false : m_envSupport.shouldStripSourceNode(textNode); - return false; - } - - /** - * Supports the XPath function GenerateID by returning a unique - * identifier string for any given DOM Node. - *

- * Warning: The base implementation uses the Node object's hashCode(), - * which is NOT guaranteed to be unique. If that method hasn't been - * overridden in this DOM ipmlementation, most Java implementions will - * derive it from the object's address and should be OK... but if - * your DOM uses a different definition of hashCode (eg hashing the - * contents of the subtree), or if your DOM may have multiple objects - * that represent a single Node in the data structure (eg via proxying), - * you may need to find another way to assign a unique identifier. - *

- * Also, be aware that if nodes are destroyed and recreated, there is - * an open issue regarding whether an ID may be reused. Currently - * we're assuming that the input document is stable for the duration - * of the XPath/XSLT operation, so this shouldn't arise in this context. - *

- * (DOM Level 3 is investigating providing a unique node "key", but - * that won't help Level 1 and Level 2 implementations.) - * - * @param node whose identifier you want to obtain - * - * @return a string which should be different for every Node object. - */ - public String getUniqueID(Node node) - { - return "N" + Integer.toHexString(node.hashCode()).toUpperCase(); - } - - /** - * Figure out whether node2 should be considered as being later - * in the document than node1, in Document Order as defined - * by the XPath model. This may not agree with the ordering defined - * by other XML applications. - *

- * There are some cases where ordering isn't defined, and neither are - * the results of this function -- though we'll generally return true. - * - * TODO: Make sure this does the right thing with attribute nodes!!! - * - * @param node1 DOM Node to perform position comparison on. - * @param node2 DOM Node to perform position comparison on . - * - * @return false if node2 comes before node1, otherwise return true. - * You can think of this as - * (node1.documentOrderPosition <= node2.documentOrderPosition). - */ - public static boolean isNodeAfter(Node node1, Node node2) - { - if (node1 == node2 || isNodeTheSame(node1, node2)) - return true; - - // Default return value, if there is no defined ordering - boolean isNodeAfter = true; - - Node parent1 = getParentOfNode(node1); - Node parent2 = getParentOfNode(node2); - - // Optimize for most common case - if (parent1 == parent2 || isNodeTheSame(parent1, parent2)) // then we know they are siblings - { - if (null != parent1) - isNodeAfter = isNodeAfterSibling(parent1, node1, node2); - else - { - // If both parents are null, ordering is not defined. - // We're returning a value in lieu of throwing an exception. - // Not a case we expect to arise in XPath, but beware if you - // try to reuse this method. - - // We can just fall through in this case, which allows us - // to hit the debugging code at the end of the function. - //return isNodeAfter; - } - } - else - { - - // General strategy: Figure out the lengths of the two - // ancestor chains, reconcile the lengths, and look for - // the lowest common ancestor. If that ancestor is one of - // the nodes being compared, it comes before the other. - // Otherwise perform a sibling compare. - // - // NOTE: If no common ancestor is found, ordering is undefined - // and we return the default value of isNodeAfter. - - // Count parents in each ancestor chain - int nParents1 = 2, nParents2 = 2; // include node & parent obtained above - - while (parent1 != null) - { - nParents1++; - - parent1 = getParentOfNode(parent1); - } - - while (parent2 != null) - { - nParents2++; - - parent2 = getParentOfNode(parent2); - } - - // Initially assume scan for common ancestor starts with - // the input nodes. - Node startNode1 = node1, startNode2 = node2; - - // If one ancestor chain is longer, adjust its start point - // so we're comparing at the same depths - if (nParents1 < nParents2) - { - // Adjust startNode2 to depth of startNode1 - int adjust = nParents2 - nParents1; - - for (int i = 0; i < adjust; i++) - { - startNode2 = getParentOfNode(startNode2); - } - } - else if (nParents1 > nParents2) - { - // adjust startNode1 to depth of startNode2 - int adjust = nParents1 - nParents2; - - for (int i = 0; i < adjust; i++) - { - startNode1 = getParentOfNode(startNode1); - } - } - - Node prevChild1 = null, prevChild2 = null; // so we can "back up" - - // Loop up the ancestor chain looking for common parent - while (null != startNode1) - { - if (startNode1 == startNode2 || isNodeTheSame(startNode1, startNode2)) // common parent? - { - if (null == prevChild1) // first time in loop? - { - - // Edge condition: one is the ancestor of the other. - isNodeAfter = (nParents1 < nParents2) ? true : false; - - break; // from while loop - } - else - { - // Compare ancestors below lowest-common as siblings - isNodeAfter = isNodeAfterSibling(startNode1, prevChild1, - prevChild2); - - break; // from while loop - } - } // end if(startNode1 == startNode2) - - // Move up one level and try again - prevChild1 = startNode1; - startNode1 = getParentOfNode(startNode1); - prevChild2 = startNode2; - startNode2 = getParentOfNode(startNode2); - } // end while(parents exist to examine) - } // end big else (not immediate siblings) - - // WARNING: The following diagnostic won't report the early - // "same node" case. Fix if/when needed. - - /* -- please do not remove... very useful for diagnostics -- - System.out.println("node1 = "+node1.getNodeName()+"("+node1.getNodeType()+")"+ - ", node2 = "+node2.getNodeName() - +"("+node2.getNodeType()+")"+ - ", isNodeAfter = "+isNodeAfter); */ - return isNodeAfter; - } // end isNodeAfter(Node node1, Node node2) - - /** - * Use DTMNodeProxy to determine whether two nodes are the same. - * - * @param node1 The first DOM node to compare. - * @param node2 The second DOM node to compare. - * @return true if the two nodes are the same. - */ - public static boolean isNodeTheSame(Node node1, Node node2) - { - if (node1 instanceof DTMNodeProxy && node2 instanceof DTMNodeProxy) - return ((DTMNodeProxy)node1).equals((DTMNodeProxy)node2); - else - return (node1 == node2); - } - - /** - * Figure out if child2 is after child1 in document order. - *

- * Warning: Some aspects of "document order" are not well defined. - * For example, the order of attributes is considered - * meaningless in XML, and the order reported by our model will - * be consistant for a given invocation but may not - * match that of either the source file or the serialized output. - * - * @param parent Must be the parent of both child1 and child2. - * @param child1 Must be the child of parent and not equal to child2. - * @param child2 Must be the child of parent and not equal to child1. - * @return true if child 2 is after child1 in document order. - */ - private static boolean isNodeAfterSibling(Node parent, Node child1, - Node child2) - { - - boolean isNodeAfterSibling = false; - short child1type = child1.getNodeType(); - short child2type = child2.getNodeType(); - - if ((Node.ATTRIBUTE_NODE != child1type) - && (Node.ATTRIBUTE_NODE == child2type)) - { - - // always sort attributes before non-attributes. - isNodeAfterSibling = false; - } - else if ((Node.ATTRIBUTE_NODE == child1type) - && (Node.ATTRIBUTE_NODE != child2type)) - { - - // always sort attributes before non-attributes. - isNodeAfterSibling = true; - } - else if (Node.ATTRIBUTE_NODE == child1type) - { - NamedNodeMap children = parent.getAttributes(); - int nNodes = children.getLength(); - boolean found1 = false, found2 = false; - - // Count from the start until we find one or the other. - for (int i = 0; i < nNodes; i++) - { - Node child = children.item(i); - - if (child1 == child || isNodeTheSame(child1, child)) - { - if (found2) - { - isNodeAfterSibling = false; - - break; - } - - found1 = true; - } - else if (child2 == child || isNodeTheSame(child2, child)) - { - if (found1) - { - isNodeAfterSibling = true; - - break; - } - - found2 = true; - } - } - } - else - { - // TODO: Check performance of alternate solution: - // There are two choices here: Count from the start of - // the document until we find one or the other, or count - // from one until we find or fail to find the other. - // Either can wind up scanning all the siblings in the worst - // case, which on a wide document can be a lot of work but - // is more typically is a short list. - // Scanning from the start involves two tests per iteration, - // but it isn't clear that scanning from the middle doesn't - // yield more iterations on average. - // We should run some testcases. - Node child = parent.getFirstChild(); - boolean found1 = false, found2 = false; - - while (null != child) - { - - // Node child = children.item(i); - if (child1 == child || isNodeTheSame(child1, child)) - { - if (found2) - { - isNodeAfterSibling = false; - - break; - } - - found1 = true; - } - else if (child2 == child || isNodeTheSame(child2, child)) - { - if (found1) - { - isNodeAfterSibling = true; - - break; - } - - found2 = true; - } - - child = child.getNextSibling(); - } - } - - return isNodeAfterSibling; - } // end isNodeAfterSibling(Node parent, Node child1, Node child2) - - //========================================================== - // SECTION: Namespace resolution - //========================================================== - - /** - * Get the depth level of this node in the tree (equals 1 for - * a parentless node). - * - * @param n Node to be examined. - * @return the number of ancestors, plus one - * @xsl.usage internal - */ - public short getLevel(Node n) - { - - short level = 1; - - while (null != (n = getParentOfNode(n))) - { - level++; - } - - return level; - } - - /** - * Given an XML Namespace prefix and a context in which the prefix - * is to be evaluated, return the Namespace Name this prefix was - * bound to. Note that DOM Level 3 is expected to provide a version of - * this which deals with the DOM's "early binding" behavior. - * - * Default handling: - * - * @param prefix String containing namespace prefix to be resolved, - * without the ':' which separates it from the localname when used - * in a Node Name. The empty sting signifies the default namespace - * at this point in the document. - * @param namespaceContext Element which provides context for resolution. - * (We could extend this to work for other nodes by first seeking their - * nearest Element ancestor.) - * - * @return a String containing the Namespace URI which this prefix - * represents in the specified context. - */ - public String getNamespaceForPrefix(String prefix, Element namespaceContext) - { - - int type; - Node parent = namespaceContext; - String namespace = null; - - if (prefix.equals("xml")) - { - namespace = QName.S_XMLNAMESPACEURI; // Hardcoded, per Namespace spec - } - else if(prefix.equals("xmlns")) - { - // Hardcoded in the DOM spec, expected to be adopted by - // Namespace spec. NOTE: Namespace declarations _must_ use - // the xmlns: prefix; other prefixes declared as belonging - // to this namespace will not be recognized and should - // probably be rejected by parsers as erroneous declarations. - namespace = "http://www.w3.org/2000/xmlns/"; - } - else - { - // Attribute name for this prefix's declaration - String declname=(prefix=="") - ? "xmlns" - : "xmlns:"+prefix; - - // Scan until we run out of Elements or have resolved the namespace - while ((null != parent) && (null == namespace) - && (((type = parent.getNodeType()) == Node.ELEMENT_NODE) - || (type == Node.ENTITY_REFERENCE_NODE))) - { - if (type == Node.ELEMENT_NODE) - { - - // Look for the appropriate Namespace Declaration attribute, - // either "xmlns:prefix" or (if prefix is "") "xmlns". - // TODO: This does not handle "implicit declarations" - // which may be created when the DOM is edited. DOM Level - // 3 will define how those should be interpreted. But - // this issue won't arise in freshly-parsed DOMs. - - // NOTE: declname is set earlier, outside the loop. - Attr attr=((Element)parent).getAttributeNode(declname); - if(attr!=null) - { - namespace = attr.getNodeValue(); - break; - } - } - - parent = getParentOfNode(parent); - } - } - - return namespace; - } - - /** - * An experiment for the moment. - */ - Map m_NSInfos = new HashMap<>(); - - /** Object to put into the m_NSInfos table that tells that a node has not been - * processed, but has xmlns namespace decls. */ - protected static final NSInfo m_NSInfoUnProcWithXMLNS = new NSInfo(false, - true); - - /** Object to put into the m_NSInfos table that tells that a node has not been - * processed, but has no xmlns namespace decls. */ - protected static final NSInfo m_NSInfoUnProcWithoutXMLNS = new NSInfo(false, - false); - - /** Object to put into the m_NSInfos table that tells that a node has not been - * processed, and has no xmlns namespace decls, and has no ancestor decls. */ - protected static final NSInfo m_NSInfoUnProcNoAncestorXMLNS = - new NSInfo(false, false, NSInfo.ANCESTORNOXMLNS); - - /** Object to put into the m_NSInfos table that tells that a node has been - * processed, and has xmlns namespace decls. */ - protected static final NSInfo m_NSInfoNullWithXMLNS = new NSInfo(true, - true); - - /** Object to put into the m_NSInfos table that tells that a node has been - * processed, and has no xmlns namespace decls. */ - protected static final NSInfo m_NSInfoNullWithoutXMLNS = new NSInfo(true, - false); - - /** Object to put into the m_NSInfos table that tells that a node has been - * processed, and has no xmlns namespace decls. and has no ancestor decls. */ - protected static final NSInfo m_NSInfoNullNoAncestorXMLNS = - new NSInfo(true, false, NSInfo.ANCESTORNOXMLNS); - - /** Vector of node (odd indexes) and NSInfos (even indexes) that tell if - * the given node is a candidate for ancestor namespace processing. */ - protected Vector m_candidateNoAncestorXMLNS = new Vector(); - - /** - * Returns the namespace of the given node. Differs from simply getting - * the node's prefix and using getNamespaceForPrefix in that it attempts - * to cache some of the data in NSINFO objects, to avoid repeated lookup. - * TODO: Should we consider moving that logic into getNamespaceForPrefix? - * - * @param n Node to be examined. - * - * @return String containing the Namespace Name (uri) for this node. - * Note that this is undefined for any nodes other than Elements and - * Attributes. - */ - public String getNamespaceOfNode(Node n) - { - - String namespaceOfPrefix; - boolean hasProcessedNS; - NSInfo nsInfo; - short ntype = n.getNodeType(); - - if (Node.ATTRIBUTE_NODE != ntype) - { - nsInfo = m_NSInfos.get(n); - hasProcessedNS = (nsInfo == null) ? false : nsInfo.m_hasProcessedNS; - } - else - { - hasProcessedNS = false; - nsInfo = null; - } - - if (hasProcessedNS) - { - namespaceOfPrefix = nsInfo.m_namespace; - } - else - { - namespaceOfPrefix = null; - - String nodeName = n.getNodeName(); - int indexOfNSSep = nodeName.indexOf(':'); - String prefix; - - if (Node.ATTRIBUTE_NODE == ntype) - { - if (indexOfNSSep > 0) - { - prefix = nodeName.substring(0, indexOfNSSep); - } - else - { - - // Attributes don't use the default namespace, so if - // there isn't a prefix, we're done. - return namespaceOfPrefix; - } - } - else - { - prefix = (indexOfNSSep >= 0) - ? nodeName.substring(0, indexOfNSSep) : ""; - } - - boolean ancestorsHaveXMLNS = false; - boolean nHasXMLNS = false; - - if (prefix.equals("xml")) - { - namespaceOfPrefix = QName.S_XMLNAMESPACEURI; - } - else - { - int parentType; - Node parent = n; - - while ((null != parent) && (null == namespaceOfPrefix)) - { - if ((null != nsInfo) - && (nsInfo.m_ancestorHasXMLNSAttrs - == NSInfo.ANCESTORNOXMLNS)) - { - break; - } - - parentType = parent.getNodeType(); - - if ((null == nsInfo) || nsInfo.m_hasXMLNSAttrs) - { - boolean elementHasXMLNS = false; - - if (parentType == Node.ELEMENT_NODE) - { - NamedNodeMap nnm = parent.getAttributes(); - - for (int i = 0; i < nnm.getLength(); i++) - { - Node attr = nnm.item(i); - String aname = attr.getNodeName(); - - if (aname.charAt(0) == 'x') - { - boolean isPrefix = aname.startsWith("xmlns:"); - - if (aname.equals("xmlns") || isPrefix) - { - if (n == parent) - nHasXMLNS = true; - - elementHasXMLNS = true; - ancestorsHaveXMLNS = true; - - String p = isPrefix ? aname.substring(6) : ""; - - if (p.equals(prefix)) - { - namespaceOfPrefix = attr.getNodeValue(); - - break; - } - } - } - } - } - - if ((Node.ATTRIBUTE_NODE != parentType) && (null == nsInfo) - && (n != parent)) - { - nsInfo = elementHasXMLNS - ? m_NSInfoUnProcWithXMLNS : m_NSInfoUnProcWithoutXMLNS; - - m_NSInfos.put(parent, nsInfo); - } - } - - if (Node.ATTRIBUTE_NODE == parentType) - { - parent = getParentOfNode(parent); - } - else - { - m_candidateNoAncestorXMLNS.addElement(parent); - m_candidateNoAncestorXMLNS.addElement(nsInfo); - - parent = parent.getParentNode(); - } - - if (null != parent) - { - nsInfo = m_NSInfos.get(parent); - } - } - - int nCandidates = m_candidateNoAncestorXMLNS.size(); - - if (nCandidates > 0) - { - if ((false == ancestorsHaveXMLNS) && (null == parent)) - { - for (int i = 0; i < nCandidates; i += 2) - { - Object candidateInfo = m_candidateNoAncestorXMLNS.elementAt(i - + 1); - - if (candidateInfo == m_NSInfoUnProcWithoutXMLNS) - { - m_NSInfos.put((Node)m_candidateNoAncestorXMLNS.elementAt(i), - m_NSInfoUnProcNoAncestorXMLNS); - } - else if (candidateInfo == m_NSInfoNullWithoutXMLNS) - { - m_NSInfos.put((Node)m_candidateNoAncestorXMLNS.elementAt(i), - m_NSInfoNullNoAncestorXMLNS); - } - } - } - - m_candidateNoAncestorXMLNS.removeAllElements(); - } - } - - if (Node.ATTRIBUTE_NODE != ntype) - { - if (null == namespaceOfPrefix) - { - if (ancestorsHaveXMLNS) - { - if (nHasXMLNS) - m_NSInfos.put(n, m_NSInfoNullWithXMLNS); - else - m_NSInfos.put(n, m_NSInfoNullWithoutXMLNS); - } - else - { - m_NSInfos.put(n, m_NSInfoNullNoAncestorXMLNS); - } - } - else - { - m_NSInfos.put(n, new NSInfo(namespaceOfPrefix, nHasXMLNS)); - } - } - } - - return namespaceOfPrefix; - } - - /** - * Returns the local name of the given node. If the node's name begins - * with a namespace prefix, this is the part after the colon; otherwise - * it's the full node name. - * - * @param n the node to be examined. - * - * @return String containing the Local Name - */ - public String getLocalNameOfNode(Node n) - { - - String qname = n.getNodeName(); - int index = qname.indexOf(':'); - - return (index < 0) ? qname : qname.substring(index + 1); - } - - /** - * Returns the element name with the namespace prefix (if any) replaced - * by the Namespace URI it was bound to. This is not a standard - * representation of a node name, but it allows convenient - * single-string comparison of the "universal" names of two nodes. - * - * @param elem Element to be examined. - * - * @return String in the form "namespaceURI:localname" if the node - * belongs to a namespace, or simply "localname" if it doesn't. - * @see #getExpandedAttributeName - */ - public String getExpandedElementName(Element elem) - { - - String namespace = getNamespaceOfNode(elem); - - return (null != namespace) - ? namespace + ":" + getLocalNameOfNode(elem) - : getLocalNameOfNode(elem); - } - - /** - * Returns the attribute name with the namespace prefix (if any) replaced - * by the Namespace URI it was bound to. This is not a standard - * representation of a node name, but it allows convenient - * single-string comparison of the "universal" names of two nodes. - * - * @param attr Attr to be examined - * - * @return String in the form "namespaceURI:localname" if the node - * belongs to a namespace, or simply "localname" if it doesn't. - * @see #getExpandedElementName - */ - public String getExpandedAttributeName(Attr attr) - { - - String namespace = getNamespaceOfNode(attr); - - return (null != namespace) - ? namespace + ":" + getLocalNameOfNode(attr) - : getLocalNameOfNode(attr); - } - - //========================================================== - // SECTION: DOM Helper Functions - //========================================================== - - /** - * Tell if the node is ignorable whitespace. Note that this can - * be determined only in the context of a DTD or other Schema, - * and that DOM Level 2 has nostandardized DOM API which can - * return that information. - * @deprecated - * - * @param node Node to be examined - * - * @return CURRENTLY HARDCODED TO FALSE, but should return true if - * and only if the node is of type Text, contains only whitespace, - * and does not appear as part of the #PCDATA content of an element. - * (Note that determining this last may require allowing for - * Entity References.) - */ - public boolean isIgnorableWhitespace(Text node) - { - - boolean isIgnorable = false; // return value - - // TODO: I can probably do something to figure out if this - // space is ignorable from just the information in - // the DOM tree. - // -- You need to be able to distinguish whitespace - // that is #PCDATA from whitespace that isn't. That requires - // DTD support, which won't be standardized until DOM Level 3. - return isIgnorable; - } - - /** - * Get the first unparented node in the ancestor chain. - * @deprecated - * - * @param node Starting node, to specify which chain to chase - * - * @return the topmost ancestor. - */ - public Node getRoot(Node node) - { - - Node root = null; - - while (node != null) - { - root = node; - node = getParentOfNode(node); - } - - return root; - } - - /** - * Get the root node of the document tree, regardless of - * whether or not the node passed in is a document node. - *

- * TODO: This doesn't handle DocumentFragments or "orphaned" subtrees - * -- it's currently returning ownerDocument even when the tree is - * not actually part of the main Document tree. We should either - * rewrite the description to say that it finds the Document node, - * or change the code to walk up the ancestor chain. - - * - * @param n Node to be examined - * - * @return the Document node. Note that this is not the correct answer - * if n was (or was a child of) a DocumentFragment or an orphaned node, - * as can arise if the DOM has been edited rather than being generated - * by a parser. - */ - public Node getRootNode(Node n) - { - int nt = n.getNodeType(); - return ( (Node.DOCUMENT_NODE == nt) || (Node.DOCUMENT_FRAGMENT_NODE == nt) ) - ? n : n.getOwnerDocument(); - } - - /** - * Test whether the given node is a namespace decl node. In DOM Level 2 - * this can be done in a namespace-aware manner, but in Level 1 DOMs - * it has to be done by testing the node name. - * - * @param n Node to be examined. - * - * @return boolean -- true iff the node is an Attr whose name is - * "xmlns" or has the "xmlns:" prefix. - */ - public boolean isNamespaceNode(Node n) - { - - if (Node.ATTRIBUTE_NODE == n.getNodeType()) - { - String attrName = n.getNodeName(); - - return (attrName.startsWith("xmlns:") || attrName.equals("xmlns")); - } - - return false; - } - - /** - * Obtain the XPath-model parent of a DOM node -- ownerElement for Attrs, - * parent for other nodes. - *

- * Background: The DOM believes that you must be your Parent's - * Child, and thus Attrs don't have parents. XPath said that Attrs - * do have their owning Element as their parent. This function - * bridges the difference, either by using the DOM Level 2 ownerElement - * function or by using a "silly and expensive function" in Level 1 - * DOMs. - *

- * (There's some discussion of future DOMs generalizing ownerElement - * into ownerNode and making it work on all types of nodes. This - * still wouldn't help the users of Level 1 or Level 2 DOMs) - *

- * - * @param node Node whose XPath parent we want to obtain - * - * @return the parent of the node, or the ownerElement if it's an - * Attr node, or null if the node is an orphan. - * - * @throws RuntimeException if the Document has no root element. - * This can't arise if the Document was created - * via the DOM Level 2 factory methods, but is possible if other - * mechanisms were used to obtain it - */ - public static Node getParentOfNode(Node node) throws RuntimeException - { - Node parent; - short nodeType = node.getNodeType(); - - if (Node.ATTRIBUTE_NODE == nodeType) - { - Document doc = node.getOwnerDocument(); - /* - TBD: - if(null == doc) - { - throw new RuntimeException(XSLMessages.createXPATHMessage(XPATHErrorResources.ER_CHILD_HAS_NO_OWNER_DOCUMENT, null));//"Attribute child does not have an owner document!"); - } - */ - - // Given how expensive the tree walk may be, we should first ask - // whether this DOM can answer the question for us. The additional - // test does slow down Level 1 DOMs slightly. DOMHelper2, which - // is currently specialized for Xerces, assumes it can use the - // Level 2 solution. We might want to have an intermediate stage, - // which would assume DOM Level 2 but not assume Xerces. - // - // (Shouldn't have to check whether impl is null in a compliant DOM, - // but let's be paranoid for a moment...) - DOMImplementation impl=doc.getImplementation(); - if(impl!=null && impl.hasFeature("Core","2.0")) - { - parent=((Attr)node).getOwnerElement(); - return parent; - } - - // DOM Level 1 solution, as fallback. Hugely expensive. - - Element rootElem = doc.getDocumentElement(); - - if (null == rootElem) - { - throw new RuntimeException( - XMLMessages.createXMLMessage( - XMLErrorResources.ER_CHILD_HAS_NO_OWNER_DOCUMENT_ELEMENT, - null)); //"Attribute child does not have an owner document element!"); - } - - parent = locateAttrParent(rootElem, node); - - } - else - { - parent = node.getParentNode(); - - // if((Node.DOCUMENT_NODE != nodeType) && (null == parent)) - // { - // throw new RuntimeException("Child does not have parent!"); - // } - } - - return parent; - } - - /** - * Given an ID, return the element. This can work only if the document - * is interpreted in the context of a DTD or Schema, since otherwise - * we don't know which attributes are or aren't IDs. - *

- * Note that DOM Level 1 had no ability to retrieve this information. - * DOM Level 2 introduced it but does not promise that it will be - * supported in all DOMs; those which can't support it will always - * return null. - *

- * TODO: getElementByID is currently unimplemented. Support DOM Level 2? - * - * @param id The unique identifier to be searched for. - * @param doc The document to search within. - * @return CURRENTLY HARDCODED TO NULL, but it should be: - * The node which has this unique identifier, or null if there - * is no such node or this DOM can't reliably recognize it. - */ - public Element getElementByID(String id, Document doc) - { - return null; - } - - /** - * The getUnparsedEntityURI function returns the URI of the unparsed - * entity with the specified name in the same document as the context - * node (see [3.3 Unparsed Entities]). It returns the empty string if - * there is no such entity. - *

- * XML processors may choose to use the System Identifier (if one - * is provided) to resolve the entity, rather than the URI in the - * Public Identifier. The details are dependent on the processor, and - * we would have to support some form of plug-in resolver to handle - * this properly. Currently, we simply return the System Identifier if - * present, and hope that it a usable URI or that our caller can - * map it to one. - * TODO: Resolve Public Identifiers... or consider changing function name. - *

- * If we find a relative URI - * reference, XML expects it to be resolved in terms of the base URI - * of the document. The DOM doesn't do that for us, and it isn't - * entirely clear whether that should be done here; currently that's - * pushed up to a higher levelof our application. (Note that DOM Level - * 1 didn't store the document's base URI.) - * TODO: Consider resolving Relative URIs. - *

- * (The DOM's statement that "An XML processor may choose to - * completely expand entities before the structure model is passed - * to the DOM" refers only to parsed entities, not unparsed, and hence - * doesn't affect this function.) - * - * @param name A string containing the Entity Name of the unparsed - * entity. - * @param doc Document node for the document to be searched. - * - * @return String containing the URI of the Unparsed Entity, or an - * empty string if no such entity exists. - */ - public String getUnparsedEntityURI(String name, Document doc) - { - - String url = ""; - DocumentType doctype = doc.getDoctype(); - - if (null != doctype) - { - NamedNodeMap entities = doctype.getEntities(); - if(null == entities) - return url; - Entity entity = (Entity) entities.getNamedItem(name); - if(null == entity) - return url; - - String notationName = entity.getNotationName(); - - if (null != notationName) // then it's unparsed - { - // The draft says: "The XSLT processor may use the public - // identifier to generate a URI for the entity instead of the URI - // specified in the system identifier. If the XSLT processor does - // not use the public identifier to generate the URI, it must use - // the system identifier; if the system identifier is a relative - // URI, it must be resolved into an absolute URI using the URI of - // the resource containing the entity declaration as the base - // URI [RFC2396]." - // So I'm falling a bit short here. - url = entity.getSystemId(); - - if (null == url) - { - url = entity.getPublicId(); - } - else - { - // This should be resolved to an absolute URL, but that's hard - // to do from here. - } - } - } - - return url; - } - - /** - * Support for getParentOfNode; walks a DOM tree until it finds - * the Element which owns the Attr. This is hugely expensive, and - * if at all possible you should use the DOM Level 2 Attr.ownerElement() - * method instead. - *

- * The DOM Level 1 developers expected that folks would keep track - * of the last Element they'd seen and could recover the info from - * that source. Obviously that doesn't work very well if the only - * information you've been presented with is the Attr. The DOM Level 2 - * getOwnerElement() method fixes that, but only for Level 2 and - * later DOMs. - * - * @param elem Element whose subtree is to be searched for this Attr - * @param attr Attr whose owner is to be located. - * - * @return the first Element whose attribute list includes the provided - * attr. In modern DOMs, this will also be the only such Element. (Early - * DOMs had some hope that Attrs might be sharable, but this idea has - * been abandoned.) - */ - private static Node locateAttrParent(Element elem, Node attr) - { - - Node parent = null; - - // This should only be called for Level 1 DOMs, so we don't have to - // worry about namespace issues. In later levels, it's possible - // for a DOM to have two Attrs with the same NodeName but - // different namespaces, and we'd need to get getAttributeNodeNS... - // but later levels also have Attr.getOwnerElement. - Attr check=elem.getAttributeNode(attr.getNodeName()); - if(check==attr) - parent = elem; - - if (null == parent) - { - for (Node node = elem.getFirstChild(); null != node; - node = node.getNextSibling()) - { - if (Node.ELEMENT_NODE == node.getNodeType()) - { - parent = locateAttrParent((Element) node, attr); - - if (null != parent) - break; - } - } - } - - return parent; - } - - /** - * The factory object used for creating nodes - * in the result tree. - */ - protected Document m_DOMFactory = null; - - /** - * Store the factory object required to create DOM nodes - * in the result tree. In fact, that's just the result tree's - * Document node... - * - * @param domFactory The DOM Document Node within whose context - * the result tree will be built. - */ - public void setDOMFactory(Document domFactory) - { - this.m_DOMFactory = domFactory; - } - - /** - * Retrieve the factory object required to create DOM nodes - * in the result tree. - * - * @return The result tree's DOM Document Node. - */ - public Document getDOMFactory() - { - - if (null == this.m_DOMFactory) - { - this.m_DOMFactory = createDocument(); - } - - return this.m_DOMFactory; - } - - /** - * Get the textual contents of the node. See - * getNodeData(Node,FastStringBuffer) for discussion of how - * whitespace nodes are handled. - * - * @param node DOM Node to be examined - * @return String containing a concatenation of all the - * textual content within that node. - * @see #getNodeData(Node,FastStringBuffer) - * - */ - public static String getNodeData(Node node) - { - - FastStringBuffer buf = StringBufferPool.get(); - String s; - - try - { - getNodeData(node, buf); - - s = (buf.length() > 0) ? buf.toString() : ""; - } - finally - { - StringBufferPool.free(buf); - } - - return s; - } - - /** - * Retrieve the text content of a DOM subtree, appending it into a - * user-supplied FastStringBuffer object. Note that attributes are - * not considered part of the content of an element. - *

- * There are open questions regarding whitespace stripping. - * Currently we make no special effort in that regard, since the standard - * DOM doesn't yet provide DTD-based information to distinguish - * whitespace-in-element-context from genuine #PCDATA. Note that we - * should probably also consider xml:space if/when we address this. - * DOM Level 3 may solve the problem for us. - * - * @param node Node whose subtree is to be walked, gathering the - * contents of all Text or CDATASection nodes. - * @param buf FastStringBuffer into which the contents of the text - * nodes are to be concatenated. - */ - public static void getNodeData(Node node, FastStringBuffer buf) - { - - switch (node.getNodeType()) - { - case Node.DOCUMENT_FRAGMENT_NODE : - case Node.DOCUMENT_NODE : - case Node.ELEMENT_NODE : - { - for (Node child = node.getFirstChild(); null != child; - child = child.getNextSibling()) - { - getNodeData(child, buf); - } - } - break; - case Node.TEXT_NODE : - case Node.CDATA_SECTION_NODE : - buf.append(node.getNodeValue()); - break; - case Node.ATTRIBUTE_NODE : - buf.append(node.getNodeValue()); - break; - case Node.PROCESSING_INSTRUCTION_NODE : - // warning(XPATHErrorResources.WG_PARSING_AND_PREPARING); - break; - default : - // ignore - break; - } - } -} --- old/src/java.xml/share/classes/com/sun/org/apache/xml/internal/utils/DOMOrder.java 2017-06-14 09:49:41.288502641 -0700 +++ /dev/null 2017-01-27 21:23:58.368196991 -0800 @@ -1,42 +0,0 @@ -/* - * reserved comment block - * DO NOT REMOVE OR ALTER! - */ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.sun.org.apache.xml.internal.utils; - -/** - * @deprecated Since the introduction of the DTM, this class will be removed. - * Nodes that implement this index can return a document order index. - * Eventually, this will be replaced by DOM 3 methods. - * (compareDocumentOrder and/or compareTreePosition.) - */ -public interface DOMOrder -{ - - /** - * Get the UID (document order index). - * - * @return integer whose relative value corresponds to document order - * -- that is, if node1.getUid()