changeset 13564:c09f6f9b8cab

8193830: Xalan Update: Xalan Java 2.7.2 Reviewed-by: lancea, clanger, andrew
author stooke
date Wed, 05 Jun 2019 04:14:02 +0100
parents e8778f8974dc
children 887c8314411d
files THIRD_PARTY_README test/javax/xml/jaxp/transform/sort/SortTest.java test/javax/xml/jaxp/transform/sort/sort-alphabet-english.out test/javax/xml/jaxp/transform/sort/sort-alphabet-english.xml test/javax/xml/jaxp/transform/sort/sort-alphabet-english.xsl test/javax/xml/jaxp/transform/sort/sort-alphabet-polish.out test/javax/xml/jaxp/transform/sort/sort-alphabet-polish.xml test/javax/xml/jaxp/transform/sort/sort-alphabet-polish.xsl test/javax/xml/jaxp/transform/sort/sort-alphabet-russian.out test/javax/xml/jaxp/transform/sort/sort-alphabet-russian.xml test/javax/xml/jaxp/transform/sort/sort-alphabet-russian.xsl
diffstat 11 files changed, 501 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/THIRD_PARTY_README	Fri Jun 15 13:05:34 2018 -0700
+++ b/THIRD_PARTY_README	Wed Jun 05 04:14:02 2019 +0100
@@ -2898,7 +2898,7 @@
   Apache Jakarta BCEL 5.1 
   Apache Jakarta Regexp 1.4 
   Apache Santuario XML Security for Java 1.5.4
-  Apache Xalan-Java 2.7.1 
+  Apache Xalan-Java 2.7.2
   Apache Xerces Java 2.10.0 
   Apache XML Resolver 1.1 
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/javax/xml/jaxp/transform/sort/SortTest.java	Wed Jun 05 04:14:02 2019 +0100
@@ -0,0 +1,126 @@
+/*
+ * Copyright (c) 2018, 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.io.StringWriter;
+import java.net.URI;
+import java.nio.file.Files;
+import java.nio.file.Paths;
+import java.util.List;
+
+import javax.xml.transform.Result;
+import javax.xml.transform.Source;
+import javax.xml.transform.Templates;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.stream.StreamResult;
+import javax.xml.transform.stream.StreamSource;
+
+import org.testng.Assert;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.DataProvider;
+import org.testng.annotations.Listeners;
+import org.testng.annotations.Test;
+
+/*
+ * @test
+ * @bug 8193830
+ * @run testng/othervm -DrunSecMngr=true SortTest
+ * @run testng/othervm SortTest
+ * @summary verify xsl:sort lang attribute
+ */
+public class SortTest {
+
+    static final String LAND_EN = "en";
+    static final String LAND_PL = "pl";
+    static final String LAND_RU = "ru";
+
+    String filepath;
+    String slash = "";
+
+    @BeforeClass
+    public void setUpClass() throws Exception {
+        String file1 = getClass().getResource("/sort-alphabet-english.xml").getFile();
+        if (System.getProperty("os.name").contains("Windows")) {
+            filepath = file1.substring(1, file1.lastIndexOf("/") + 1);
+            slash = "/";
+        } else {
+            filepath = file1.substring(0, file1.lastIndexOf("/") + 1);
+        }
+    }
+
+    /*
+     * DataProvider fields:
+     * lang, xml, xsl, gold file
+     */
+    @DataProvider(name = "parameters")
+    public Object[][] getParameters() {
+
+        return new Object[][]{
+            {LAND_EN, "sort-alphabet-english.xml", "sort-alphabet-english.xsl", "sort-alphabet-english.out"},
+            {LAND_PL, "sort-alphabet-polish.xml", "sort-alphabet-polish.xsl", "sort-alphabet-polish.out"},
+            {LAND_RU, "sort-alphabet-russian.xml", "sort-alphabet-russian.xsl", "sort-alphabet-russian.out"},};
+    }
+
+    @Test(dataProvider = "parameters")
+    public final void testTransform(String lang, String xml, String xsl, String gold)
+            throws Exception {
+
+        StringWriter sw = new StringWriter();
+        // Create transformer factory
+        TransformerFactory factory = TransformerFactory.newInstance();
+
+        // Use the factory to create a template containing the xsl file
+        Templates template = factory.newTemplates(new StreamSource(getClass().getResourceAsStream(xsl)));
+        // Use the template to create a transformer
+        Transformer xformer = template.newTransformer();
+        xformer.setParameter("lang", lang);
+        // Prepare the input and output files
+        Source source = new StreamSource(getClass().getResourceAsStream(xml));
+
+        /*
+             * The following may be used to produce gold files.
+             * Using however the original gold files, and compare without considering
+             * the format
+         */
+        //String output = getClass().getResource(gold).getPath();
+        //Result result = new StreamResult(new FileOutputStream(output));
+        // use the following to verify the output against the pre-generated one
+        Result result = new StreamResult(sw);
+
+        // Apply the xsl file to the source file and write the result to the
+        // output file
+        xformer.transform(source, result);
+
+        String out = sw.toString();
+
+        List<String> lines = Files.readAllLines(Paths.get(filepath + gold));
+        String[] resultLines = out.split("\n");
+        int i = 0;
+
+        // the purpose is to test sort, so ignore the format of the output
+
+        for (String line : lines) {
+            Assert.assertEquals(resultLines[i++].trim(), line.trim());
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/javax/xml/jaxp/transform/sort/sort-alphabet-english.out	Wed Jun 05 04:14:02 2019 +0100
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8"?><root>
+<p>lang: en</p>
+<ul>
+<li>A</li>
+<li>C</li>
+<li>D</li>
+<li>E</li>
+<li>F</li>
+<li>G</li>
+<li>H</li>
+<li>I</li>
+<li>J</li>
+<li>K</li>
+<li>L</li>
+<li>M</li>
+<li>N</li>
+<li>O</li>
+<li>P</li>
+<li>Q</li>
+<li>R</li>
+<li>S</li>
+<li>T</li>
+<li>U</li>
+<li>V</li>
+<li>W</li>
+<li>X</li>
+<li>Y</li>
+<li>Z</li>
+</ul>
+</root>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/javax/xml/jaxp/transform/sort/sort-alphabet-english.xml	Wed Jun 05 04:14:02 2019 +0100
@@ -0,0 +1,46 @@
+<?xml version="1.0" encoding="UTF-8"?>
+  <!--
+   * 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.
+  -->
+<alphabet language="en">
+  <character>A</character>
+  <character>E</character>
+  <character>C</character>
+  <character>D</character>
+  <character>F</character>
+  <character>G</character>
+  <character>H</character>
+  <character>I</character>
+  <character>J</character>
+  <character>K</character>
+  <character>L</character>
+  <character>M</character>
+  <character>N</character>
+  <character>Y</character>
+  <character>O</character>
+  <character>P</character>
+  <character>Q</character>
+  <character>U</character>
+  <character>R</character>
+  <character>S</character>
+  <character>V</character>
+  <character>W</character>
+  <character>T</character>
+  <character>X</character>
+  <character>Z</character>
+</alphabet>
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/javax/xml/jaxp/transform/sort/sort-alphabet-english.xsl	Wed Jun 05 04:14:02 2019 +0100
@@ -0,0 +1,40 @@
+<?xml version="1.0" encoding="UTF-8"?>
+  <!--
+   * 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.
+  -->
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
+  <xsl:output method="xml" version="1.0" omit-xml-declaration="no" encoding="UTF-8" indent="yes" xml:space="preserve" />
+  <!-- <xsl:output method="html" doctype-system="http://www.w3.org/TR/html4/strict.dtd" doctype-public="-//W3C//DTD HTML 
+    4.01//EN" version="4.0" encoding="UTF-8" indent="yes" xml:lang="$lang" omit-xml-declaration="no"/> -->
+  <xsl:param name="lang" />
+  <xsl:template match="alphabet">
+    <root>
+      <p>lang: <xsl:value-of select="$lang" /></p>
+      <ul>
+        <xsl:apply-templates select="character">
+          <xsl:sort select="." lang="{$lang}" order="ascending" />
+        </xsl:apply-templates>
+      </ul>
+    </root>
+  </xsl:template>
+  <xsl:template match="character">
+    <li>
+      <xsl:value-of select="text()" />
+    </li>
+  </xsl:template>
+</xsl:stylesheet>
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/javax/xml/jaxp/transform/sort/sort-alphabet-polish.out	Wed Jun 05 04:14:02 2019 +0100
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="UTF-8"?><root>
+<p>lang: pl</p>
+<ul>
+<li>A</li>
+<li>Ą</li>
+<li>B</li>
+<li>C</li>
+<li>Ć</li>
+<li>D</li>
+<li>E</li>
+<li>Ę</li>
+<li>F</li>
+<li>G</li>
+<li>H</li>
+<li>I</li>
+<li>J</li>
+<li>K</li>
+<li>L</li>
+<li>Ł</li>
+<li>M</li>
+<li>N</li>
+<li>Ń</li>
+<li>O</li>
+<li>Ó</li>
+<li>P</li>
+<li>R</li>
+<li>S</li>
+<li>Ś</li>
+<li>T</li>
+<li>U</li>
+<li>W</li>
+<li>Y</li>
+<li>Z</li>
+<li>Ź</li>
+<li>Ż</li>
+</ul>
+</root>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/javax/xml/jaxp/transform/sort/sort-alphabet-polish.xml	Wed Jun 05 04:14:02 2019 +0100
@@ -0,0 +1,52 @@
+<?xml version="1.0" encoding="UTF-8"?>
+  <!--
+   * 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.
+  -->
+<alphabet language="pl">
+  <character>A</character>
+  <character>Ż</character>
+  <character>B</character>
+  <character>C</character>
+  <character>Ć</character>
+  <character>D</character>
+  <character>Ł</character>
+  <character>E</character>
+  <character>Ę</character>
+  <character>F</character>
+  <character>G</character>
+  <character>H</character>
+  <character>I</character>
+  <character>J</character>
+  <character>K</character>
+  <character>L</character>
+  <character>Z</character>
+  <character>Ź</character>
+  <character>M</character>
+  <character>N</character>
+  <character>Ń</character>
+  <character>O</character>
+  <character>Ó</character>
+  <character>P</character>
+  <character>R</character>
+  <character>S</character>
+  <character>Ś</character>
+  <character>T</character>
+  <character>U</character>
+  <character>W</character>
+  <character>Ą</character>
+  <character>Y</character>
+</alphabet>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/javax/xml/jaxp/transform/sort/sort-alphabet-polish.xsl	Wed Jun 05 04:14:02 2019 +0100
@@ -0,0 +1,39 @@
+<?xml version="1.0" encoding="UTF-8"?>
+  <!--
+   * 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.
+  -->
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
+  <xsl:output method="xml" version="1.0" omit-xml-declaration="no" encoding="UTF-8" indent="yes" xml:space="preserve" />
+  <!-- <xsl:output method="html" doctype-system="http://www.w3.org/TR/html4/strict.dtd" doctype-public="-//W3C//DTD HTML 
+    4.01//EN" version="4.0" encoding="UTF-8" indent="yes" xml:lang="$lang" omit-xml-declaration="no"/> -->
+  <xsl:param name="lang" />
+  <xsl:template match="alphabet">
+    <root>
+      <p>lang: <xsl:value-of select="$lang" /></p>
+      <ul>
+        <xsl:apply-templates select="character">
+          <xsl:sort select="." lang="{$lang}" order="ascending" />
+        </xsl:apply-templates>
+      </ul>
+    </root>
+  </xsl:template>
+  <xsl:template match="character">
+    <li>
+      <xsl:value-of select="text()" />
+    </li>
+  </xsl:template>
+</xsl:stylesheet>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/javax/xml/jaxp/transform/sort/sort-alphabet-russian.out	Wed Jun 05 04:14:02 2019 +0100
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="UTF-8"?><root>
+<p>lang: ru</p>
+<ul>
+<li>А</li>
+<li>Б</li>
+<li>В</li>
+<li>Г</li>
+<li>Д</li>
+<li>Е</li>
+<li>Ё</li>
+<li>Ж</li>
+<li>З</li>
+<li>И</li>
+<li>Й</li>
+<li>К</li>
+<li>Л</li>
+<li>М</li>
+<li>Н</li>
+<li>О</li>
+<li>П</li>
+<li>Р</li>
+<li>С</li>
+<li>Т</li>
+<li>У</li>
+<li>Ф</li>
+<li>Х</li>
+<li>Ц</li>
+<li>Ч</li>
+<li>Ш</li>
+<li>Щ</li>
+<li>Ъ</li>
+<li>Ы</li>
+<li>Ь</li>
+<li>Э</li>
+<li>Ю</li>
+<li>Я</li>
+</ul>
+</root>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/javax/xml/jaxp/transform/sort/sort-alphabet-russian.xml	Wed Jun 05 04:14:02 2019 +0100
@@ -0,0 +1,53 @@
+<?xml version="1.0" encoding="UTF-8"?>
+  <!--
+   * 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.
+  -->
+<alphabet language="ru">
+  <character>А</character>
+  <character>Б</character>
+  <character>В</character>
+  <character>Г</character>
+  <character>Д</character>
+  <character>Е</character>
+  <character>Ё</character>
+  <character>Ж</character>
+  <character>З</character>
+  <character>Й</character>
+  <character>П</character>
+  <character>Я</character>
+  <character>К</character>
+  <character>Л</character>
+  <character>С</character>
+  <character>М</character>
+  <character>Н</character>
+  <character>О</character>
+  <character>Р</character>
+  <character>И</character>
+  <character>Т</character>
+  <character>Ф</character>
+  <character>Х</character>
+  <character>Ц</character>
+  <character>У</character>
+  <character>Ш</character>
+  <character>Щ</character>
+  <character>Ъ</character>
+  <character>Ы</character>
+  <character>Ч</character>
+  <character>Ь</character>
+  <character>Э</character>
+  <character>Ю</character>
+</alphabet>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/javax/xml/jaxp/transform/sort/sort-alphabet-russian.xsl	Wed Jun 05 04:14:02 2019 +0100
@@ -0,0 +1,39 @@
+<?xml version="1.0" encoding="UTF-8"?>
+  <!--
+   * 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.
+  -->
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
+  <xsl:output method="xml" version="1.0" omit-xml-declaration="no" encoding="UTF-8" indent="yes" xml:space="preserve" />
+  <!-- <xsl:output method="html" doctype-system="http://www.w3.org/TR/html4/strict.dtd" doctype-public="-//W3C//DTD HTML 
+    4.01//EN" version="4.0" encoding="UTF-8" indent="yes" xml:lang="$lang" omit-xml-declaration="no"/> -->
+  <xsl:param name="lang" />
+  <xsl:template match="alphabet">
+    <root>
+      <p>lang: <xsl:value-of select="$lang" /></p>
+      <ul>
+        <xsl:apply-templates select="character">
+          <xsl:sort select="." lang="{$lang}" order="ascending" />
+        </xsl:apply-templates>
+      </ul>
+    </root>
+  </xsl:template>
+  <xsl:template match="character">
+    <li>
+      <xsl:value-of select="text()" />
+    </li>
+  </xsl:template>
+</xsl:stylesheet>
\ No newline at end of file