8193830: Xalan Update: Xalan Java 2.7.2

Reviewed-by: lancea
This commit is contained in:
Joe Wang 2018-02-01 15:53:51 -08:00
parent 697c3fc073
commit 0584441390
17 changed files with 527 additions and 22 deletions

View File

@ -97,7 +97,6 @@ final class FunctionAvailableCall extends FunctionCall {
* the specified method is found in the specifed class.
*/
private boolean hasMethods() {
LiteralExpr arg = (LiteralExpr)_arg;
// Get the class name from the namespace uri
String className = getClassNameFromUri(_namespaceOfFunct);
@ -110,7 +109,7 @@ final class FunctionAvailableCall extends FunctionCall {
int lastDotIndex = functionName.lastIndexOf('.');
if (lastDotIndex > 0) {
methodName = functionName.substring(lastDotIndex+1);
if (className != null && !className.equals(""))
if (className != null && className.length() != 0)
className = className + "." + functionName.substring(0, lastDotIndex);
else
className = functionName.substring(0, lastDotIndex);

View File

@ -66,7 +66,7 @@ final class Sort extends Instruction implements Closure {
private AttributeValue _order;
private AttributeValue _caseOrder;
private AttributeValue _dataType;
private String _lang; // bug! see 26869
private AttributeValue _lang; // bug! see 26869, see XALANJ-2546
private String _className = null;
private List<VariableRefBase> _closureVars = null;
@ -154,13 +154,11 @@ final class Sort extends Instruction implements Closure {
}
_dataType = AttributeValue.create(this, val, parser);
_lang = getAttribute("lang"); // bug! see 26869
// val = getAttribute("lang");
// _lang = AttributeValue.create(this, val, parser);
val = getAttribute("lang");
_lang = AttributeValue.create(this, val, parser);
// Get the case order; default is language dependant
val = getAttribute("case-order");
_caseOrder = AttributeValue.create(this, val, parser);
val = getAttribute("case-order");
_caseOrder = AttributeValue.create(this, val, parser);
}
/**
@ -179,6 +177,7 @@ final class Sort extends Instruction implements Closure {
_order.typeCheck(stable);
_caseOrder.typeCheck(stable);
_dataType.typeCheck(stable);
_lang.typeCheck(stable);
return Type.Void;
}
@ -196,16 +195,14 @@ final class Sort extends Instruction implements Closure {
_order.translate(classGen, methodGen);
}
public void translateCaseOrder(ClassGenerator classGen,
public void translateCaseOrder(ClassGenerator classGen,
MethodGenerator methodGen) {
_caseOrder.translate(classGen, methodGen);
_caseOrder.translate(classGen, methodGen);
}
public void translateLang(ClassGenerator classGen,
MethodGenerator methodGen) {
final ConstantPoolGen cpg = classGen.getConstantPool();
final InstructionList il = methodGen.getInstructionList();
il.append(new PUSH(cpg, _lang)); // bug! see 26869
_lang.translate(classGen, methodGen);
}
/**

View File

@ -570,7 +570,7 @@ public class AdaptiveResultTreeImpl extends SimpleResultTreeImpl
if (_openElementName != null) {
int index;
if ((index =_openElementName.indexOf(":")) < 0)
if ((index =_openElementName.indexOf(':')) < 0)
_dom.startElement(null, _openElementName, _openElementName, _attributes);
else {
String uri =_dom.getNamespaceURI(_openElementName.substring(0,index));
@ -682,7 +682,7 @@ public class AdaptiveResultTreeImpl extends SimpleResultTreeImpl
public void addAttribute(String qName, String value)
{
// "prefix:localpart" or "localpart"
int colonpos = qName.indexOf(":");
int colonpos = qName.indexOf(':');
String uri = EMPTY_STRING;
String localName = qName;
if (colonpos >0)

View File

@ -1425,8 +1425,8 @@ public final class BasisLibrary {
* This method should only be invoked if the name attribute is an AVT
*/
public static void checkAttribQName(String name) {
final int firstOccur = name.indexOf(":");
final int lastOccur = name.lastIndexOf(":");
final int firstOccur = name.indexOf(':');
final int lastOccur = name.lastIndexOf(':');
final String localName = name.substring(lastOccur + 1);
if (firstOccur > 0) {

View File

@ -354,7 +354,7 @@ public abstract class DTMDefaultBase implements DTM
while (low <= high)
{
int mid = (low + high) / 2;
int mid = (low + high) >>> 1;
int c = list[mid];
if (c > value)

View File

@ -669,9 +669,10 @@ public class NodeVector implements Serializable, Cloneable
/*
* Pick a pivot and move it out of the way
*/
int pivot = a[(lo + hi) / 2];
int mid = (lo + hi) >>> 1;
int pivot = a[mid];
a[(lo + hi) / 2] = a[hi];
a[mid] = a[hi];
a[hi] = pivot;
while (lo < hi)

View File

@ -1,4 +1,4 @@
## Apache Xalan v2.7.1
## Apache Xalan v2.7.2
### Apache Xalan Notice
<pre>
@ -11,6 +11,11 @@
This product includes software developed by
The Apache Software Foundation (http://www.apache.org/).
Specifically, we only include the XSLTC portion of the source from the Xalan distribution.
The Xalan project has two processors: an interpretive one (Xalan Interpretive) and a
compiled one (The XSLT Compiler (XSLTC)). We *only* use the XSLTC part of Xalan; We use
the source from the packages that are part of the XSLTC sources.
Portions of this software was originally based on the following:
- software copyright (c) 1999-2002, Lotus Development Corporation., http://www.lotus.com.

View File

@ -0,0 +1,129 @@
/*
* 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.
*/
package transform.sort;
import static jaxp.library.JAXPTestUtilities.getSystemProperty;
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
* @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
* @run testng/othervm -DrunSecMngr=true transform.sort.SortTest
* @run testng/othervm transform.sort.SortTest
* @summary verify xsl:sort lang attribute
*/
@Listeners({jaxp.library.FilePolicy.class})
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 (getSystemProperty("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());
}
}
}

View File

@ -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>

View File

@ -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>

View File

@ -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>

View File

@ -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>

View File

@ -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>

View File

@ -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>

View File

@ -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>

View File

@ -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>

View File

@ -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>