curcuru 02/02/11 07:27:06
Added: test/tests/bugzilla Bugzilla6181.java Bugzilla6181.xml
Bugzilla6181.xsl
Log:
Reproduce Bugzilla6181
Revision Changes Path
1.1 xml-xalan/test/tests/bugzilla/Bugzilla6181.java
Index: Bugzilla6181.java
===================================================================
/*
* Covered by The Apache Software License, Version 1.1
* See xml-xalan/License
*/
// Common Qetest / Xalan testing imports
import org.apache.qetest.Datalet;
import org.apache.qetest.Logger;
import org.apache.qetest.TestletImpl;
import java.io.BufferedReader;
import java.io.File;
import java.io.InputStreamReader;
import java.io.IOException;
import java.util.Date;
import java.util.HashSet;
import java.util.Properties;
import javax.xml.transform.*;
import javax.xml.transform.stream.*;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.w3c.dom.DocumentFragment;
import org.w3c.dom.traversal.NodeIterator;
import org.apache.xalan.extensions.XSLProcessorContext;
import org.apache.xalan.templates.ElemExtensionCall;
/**
* Testlet for reproducing Bugzilla reported bugs.
* @author [EMAIL PROTECTED]
* @author [EMAIL PROTECTED]
*/
public class Bugzilla6181 extends TestletImpl
{
// Initialize our classname for TestletImpl's main() method - must be
updated!
static { thisClassName = "Bugzilla6181"; }
/** Cheap-o validation for extension call */
static int extCounter = 0;
/**
* Write Minimal code to reproduce your Bugzilla bug report.
* Many Bugzilla tests won't bother with a datalet; they'll
* just have the data to reproduce the bug encoded by default.
* @param d (optional) Datalet to use as data point for the test.
*/
public void execute(Datalet d)
{
// Use logger.logMsg(...) instead of System.out.println(...)
logger.logMsg(Logger.STATUSMSG, "Reproducing Bugzilla#6181");
logger.logMsg(logger.STATUSMSG, "extCounter(before) = " +
extCounter);
try
{
TransformerFactory factory = TransformerFactory.newInstance();
// Simply transform our stylesheet..
Transformer transformer = factory.newTransformer(new
StreamSource("Bugzilla6181.xsl"));
transformer.transform(new StreamSource("Bugzilla6181.xml"),
new StreamResult("Bugzilla6181.output"));
logger.checkPass("Crash test: produced unvalidated output into:
Bugzilla6181.output");
}
catch (Throwable t)
{
logger.logThrowable(logger.ERRORMSG, t, "Unexpected exception");
logger.checkErr("Unexpected exception: " + t.toString());
}
// Then see how many times we've been called
logger.logMsg(logger.STATUSMSG, "extCounter(after) = " + extCounter);
}
/**
* <a href="http://nagoya.apache.org/bugzilla/show_bug.cgi?id=6181">
* Link to Bugzilla report</a>
* @return Problems with value-of and extension function.
*/
public String getDescription()
{
return "Problems with value-of and extension function";
}
private String makeString( NodeIterator it ) {
String source = null;
StringBuffer sourceBuf = new StringBuffer();
Node n;
while((n = it.nextNode()) != null) {
sourceBuf.append( n.getNodeValue() );
}
return sourceBuf.toString();
}
// initcap
// Handles function nn:initcap(<XPath-Expr>)
//
public String initcap( NodeIterator it ) {
String source = makeString( it );
extCounter++;
logger.logMsg(logger.INFOMSG, "initcap(ni) called with: " + source);
// Now do the initcap thing and return it...
if( source.length() > 1 ) {
return source.substring(0,1).toUpperCase() + source.substring( 1 );
}
return "";
}
private String makeString( DocumentFragment fragment ) {
NodeList nodes = fragment.getChildNodes();
StringBuffer sourceBuf = new StringBuffer();
for( int i = 0; i < nodes.getLength(); ++i ) {
String s = nodes.item(i).getNodeValue();
if( s != null ) sourceBuf.append( s );
}
return sourceBuf.toString();
}
// initcap
// Handles function nn:initcap(<XPath-Expr>)
//
public String initcap( DocumentFragment fragment ) {
try {
String source = makeString( fragment );
extCounter++;
logger.logMsg(logger.INFOMSG, "initcap(f) called with: " + source);
// Now do the initcap thing and return it...
if( source.length() > 1 ) {
return source.substring(0,1).toUpperCase() + source.substring( 1 );
}
} catch( Exception e ) {
e.printStackTrace();
}
return "";
}
}
1.1 xml-xalan/test/tests/bugzilla/Bugzilla6181.xml
Index: Bugzilla6181.xml
===================================================================
<?xml version="1.0" encoding="UTF-8"?>
<!-- [EMAIL PROTECTED] (Jay Walters) -->
<!-- Note: bug did not have .dtd attached; skipping
<!DOCTYPE application SYSTEM "intermediate.dtd">
-->
<application name="cart" package="com.netnumina.cart">
<component datasource="cartDs" name="cart" package="com.netnumina.cart">
<dependent id="xmi.9" name="Address" plural="Addresses"
smart-type="Object">
<description/>
<fields>
<field fkey="true" idref="xmi.2" name="orderId" type="int"/>
<field key="1" name="addressId" type="int"/>
<field name="street_1" type="String"/>
<field name="street_2" type="String"/>
<field name="postalCode" type="String"/>
<field descr="6" list="2" name="city" type="String"/>
<field descr="7" list="3" name="state" type="String"/>
</fields>
<associations>
<parent idref="xmi.2" name="undefined">
<fields>
<field key="1" name="orderId" type="int"/>
</fields>
</parent>
</associations>
</dependent>
<entity id="xmi.2" name="Order" plural="Orders" type="bmp">
<description/>
<fields>
<field descr="1" key="1" list="1" name="orderId" type="int"/>
<field descr="2" list="2" name="orderDate" type="Date"/>
</fields>
<constructors/>
<methods/>
<associations>
<child idref="xmi.9" name="shipTo" smart-type="Object">
<fields>
<field key="1" name="orderId" type="int"/>
</fields>
</child>
</associations>
</entity>
</component>
</application>
1.1 xml-xalan/test/tests/bugzilla/Bugzilla6181.xsl
Index: Bugzilla6181.xsl
===================================================================
<?xml version="1.0"?>
<!--
- Title: action.xsl
- Purpose: An XSL stylesheet for processing an intermediate XML file
- and generating the action classes required for our simple UI
- for each entity in the file.
-
- $Revision: 1.1 $
- $Date: 2002/02/11 15:27:06 $
- $Author: curcuru $
-->
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:lxslt="http://xml.apache.org/xslt"
xmlns:ns="Bugzilla6181"
extension-element-prefixes="ns"
version="1.0"
exclude-result-prefixes="#default">
<xsl:output method="text" indent="no"/>
<xsl:template match="/">
<xsl:apply-templates select="//component/dependent"/>
</xsl:template>
<xsl:template match="dependent">
<xsl:variable name="parentName"
select="id(associations/parent/@idref)/@name"/>
<xsl:variable name="parentName2">
<xsl:value-of select="id(associations/parent/@idref)/@name"/>
</xsl:variable>
<xsl:value-of select="$parentName"/>EditForm parentForm =
(<xsl:value-of select="$parentName"/>EditForm) session.getAttribute(
"<xsl:value-of select='ns:initcap($parentName)'/>EditForm" );
<xsl:value-of select="$parentName2"/>Proxy sessionProxy = new
<xsl:value-of select="ns:initcap($parentName2)"/>Proxy();
</xsl:template>
</xsl:stylesheet>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]