sboag 99/12/15 08:25:14
Modified: src/org/apache/xalan/xpath/xml FormatterToHTML.java
src/org/apache/xalan/xslt ElemAttributeSet.java
ElemLiteralResult.java ElemTemplate.java
ElemTemplateElement.java FuncDocument.java
XSLTEngineImpl.java
Log:
Fixed regression with a flush that broke attribute sets, fixed attribute set
evaluation order.
Revision Changes Path
1.15 +23 -53
xml-xalan/src/org/apache/xalan/xpath/xml/FormatterToHTML.java
Index: FormatterToHTML.java
===================================================================
RCS file:
/home/cvs/xml-xalan/src/org/apache/xalan/xpath/xml/FormatterToHTML.java,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -r1.14 -r1.15
--- FormatterToHTML.java 1999/12/14 23:01:14 1.14
+++ FormatterToHTML.java 1999/12/15 16:25:13 1.15
@@ -68,23 +68,7 @@
*/
public class FormatterToHTML extends FormatterToXML
{
- static char[] s_escapetb = {'%', '<', '>', '{', '}', '[', ']', '|', '^',
'"' /* , ' ', '#' '\\', '\'' */};
-
- /**
- * Tell if the character should be escaped in a URL attribute.
- */
- boolean isURLEscapeChar(char c)
- {
- int n = s_escapetb.length;
- for(int i = 0; i < n; i++)
- {
- if(s_escapetb[i] == c)
- return true;
- }
- return false;
- }
-
- StringVector m_parents = new StringVector();
+ // StringVector m_parents = new StringVector();
BoolStack m_isRawStack = new BoolStack();
boolean m_inBlockElem = false;
@@ -493,7 +477,7 @@
m_isRawStack.push(elemDesc.is(ElemDesc.RAW));
m_currentElementName = nameUpper;
- m_parents.push(m_currentElementName);
+ // m_parents.push(m_currentElementName);
this.accum('<');
this.accum(name);
@@ -527,7 +511,7 @@
// name = name.toUpperCase();
boolean hasChildNodes = childNodesWereAdded();
// System.out.println(m_currentElementName);
- m_parents.pop();
+ // m_parents.pop();
m_isRawStack.pop();
String nameUpper = name.toUpperCase();
@@ -619,6 +603,9 @@
}
}
+ static final int MASK1 = 0xFF00;
+ static final int MASK2 = 0x00FF;
+
/**
* Write the specified <var>string</var> after substituting non ASCII
characters,
* with <CODE>%HH</CODE>, where HH is the hex of the byte value.
@@ -631,42 +618,25 @@
public void writeAttrURI(String string, String encoding)
throws SAXException
{
- // Not sure if it's OK to use the URLEncoder...
- if(true)
- {
- string = java.net.URLEncoder.encode(string);
- accum(string);
- }
- else
- {
- char[] stringArray = string.toCharArray();
- int len = stringArray.length;
+ char[] stringArray = string.toCharArray();
+ int len = stringArray.length;
- for (int i = 0; i < len; i ++)
+ for (int i = 0; i < len; i ++)
+ {
+ char ch = stringArray[i];
+ int b1 = (int)((((int)ch) & MASK1) >> 8);
+ // if first 8 bytes are 0, no need to append them.
+ if (b1 != 0)
+ {
+ int b2 = (int)(((int)ch) & MASK2);
+ accum("%");
+ accum(Integer.toHexString(b1));
+ accum("%");
+ accum(Integer.toHexString(b2));
+ }
+ else
{
- char ch = stringArray[i];
- if(((ch > 0x1F) && // X'00 - 1F' not valid
- (ch < 0x7F)) && // X'7F' not valid
- !isURLEscapeChar(ch) ) // characters in the table
- {
- accum(ch); // valid character, append it
- }
- else
- {
- // need to escape the character
- int mask1 = 0xFF00;
- int mask2 = 0x00FF;
- int b1 = (int)((((int)ch) & mask1) >> 8);
- int b2 = (int)(((int)ch) & mask2);
- // if first 8 bytes are 0, no need to append them.
- if (b1 != 0)
- {
- accum("%");
- accum(Integer.toHexString(b1));
- }
- accum("%");
- accum(Integer.toHexString(b2));
- }
+ accum(ch);
}
}
}
1.2 +1 -1 xml-xalan/src/org/apache/xalan/xslt/ElemAttributeSet.java
Index: ElemAttributeSet.java
===================================================================
RCS file:
/home/cvs/xml-xalan/src/org/apache/xalan/xslt/ElemAttributeSet.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- ElemAttributeSet.java 1999/11/08 20:56:18 1.1
+++ ElemAttributeSet.java 1999/12/15 16:25:13 1.2
@@ -125,13 +125,13 @@
}
m_stylesheet.m_stylesheetRoot.m_attrSetStack.push(this);
+ super.execute(processor, sourceTree, sourceNode, mode);
ElemAttribute attr = (ElemAttribute)getFirstChild();
while(null != attr)
{
attr.execute(processor, sourceTree, sourceNode, mode);
attr = (ElemAttribute)attr.getNextSibling();
}
- super.execute(processor, sourceTree, sourceNode, mode);
m_stylesheet.m_stylesheetRoot.m_attrSetStack.pop();
}
1.8 +1 -1
xml-xalan/src/org/apache/xalan/xslt/ElemLiteralResult.java
Index: ElemLiteralResult.java
===================================================================
RCS file:
/home/cvs/xml-xalan/src/org/apache/xalan/xslt/ElemLiteralResult.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- ElemLiteralResult.java 1999/12/03 15:44:18 1.7
+++ ElemLiteralResult.java 1999/12/15 16:25:13 1.8
@@ -229,7 +229,7 @@
String srcURI = ns.m_uri;
// Look for an alias for this URI. If one is found, use it as the
result URI
String aliasURI = m_stylesheet.lookForAlias(srcURI);
- if(!aliasURI.equalsIgnoreCase(desturi)) // TODO: Check for
extension namespaces
+ if(!aliasURI.equals(desturi)) // TODO: Check for extension
namespaces
{
if(m_stylesheet.shouldExcludeResultNamespaceNode(this, prefix,
srcURI))
{
1.2 +3 -3 xml-xalan/src/org/apache/xalan/xslt/ElemTemplate.java
Index: ElemTemplate.java
===================================================================
RCS file: /home/cvs/xml-xalan/src/org/apache/xalan/xslt/ElemTemplate.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- ElemTemplate.java 1999/11/08 20:56:26 1.1
+++ ElemTemplate.java 1999/12/15 16:25:13 1.2
@@ -143,8 +143,8 @@
else // if(null == sourceNode)
{
processor.error(this, sourceNode,
- XSLTErrorResources.ERROR0005);
- //"sourceNode is null in
handleApplyTemplatesInstruction!");
+ XSLTErrorResources.ERROR0005);
+ //"sourceNode is null in handleApplyTemplatesInstruction!");
+ }
}
-}
}
1.10 +5 -1
xml-xalan/src/org/apache/xalan/xslt/ElemTemplateElement.java
Index: ElemTemplateElement.java
===================================================================
RCS file:
/home/cvs/xml-xalan/src/org/apache/xalan/xslt/ElemTemplateElement.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- ElemTemplateElement.java 1999/12/14 22:25:10 1.9
+++ ElemTemplateElement.java 1999/12/15 16:25:13 1.10
@@ -539,7 +539,7 @@
SAXException
{
processor.m_mustFlushStartDoc = true;
- processor.flushPending();
+ // processor.flushPending();
DocumentHandler savedFListener = processor.m_flistener;
StringWriter sw = new StringWriter();
OutputFormat formatter = new OutputFormat("text",
@@ -548,6 +548,8 @@
processor.m_flistener =
m_stylesheet.m_stylesheetRoot.makeSAXSerializer(sw, formatter);
+ boolean savedMustFlushStartDoc = processor.m_mustFlushStartDoc;
+ boolean savedPendingStartDoc = processor.m_pendingStartDoc;
String savedPendingName = processor.m_pendingElementName;
processor.m_pendingElementName = null;
AttributeListImpl savedPendingAttributes = processor.m_pendingAttributes;
@@ -558,6 +560,8 @@
processor.m_pendingElementName = savedPendingName;
processor.m_pendingAttributes = savedPendingAttributes;
processor.m_flistener = savedFListener;
+ processor.m_mustFlushStartDoc = savedMustFlushStartDoc;
+ processor.m_pendingStartDoc = savedPendingStartDoc;
return sw.toString();
}
1.6 +1 -1 xml-xalan/src/org/apache/xalan/xslt/FuncDocument.java
Index: FuncDocument.java
===================================================================
RCS file: /home/cvs/xml-xalan/src/org/apache/xalan/xslt/FuncDocument.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- FuncDocument.java 1999/12/14 22:25:10 1.5
+++ FuncDocument.java 1999/12/15 16:25:13 1.6
@@ -168,7 +168,7 @@
uri = ss.getBaseIdentifier();
}
}
- else
+
{
// TODO: Note the the warning calls below go through XPath, instead
// of XSLT, as the should.
1.21 +20 -0 xml-xalan/src/org/apache/xalan/xslt/XSLTEngineImpl.java
Index: XSLTEngineImpl.java
===================================================================
RCS file: /home/cvs/xml-xalan/src/org/apache/xalan/xslt/XSLTEngineImpl.java,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -r1.20 -r1.21
--- XSLTEngineImpl.java 1999/12/14 00:21:55 1.20
+++ XSLTEngineImpl.java 1999/12/15 16:25:13 1.21
@@ -3891,6 +3891,24 @@
}
boolean m_mustFlushStartDoc = false;
+
+ /**
+ * Check to see if the output prefix should be excluded.
+ */
+ private String excludePrefix(String name)
+ {
+ int indexOfNSSep = name.indexOf(':');
+ if(indexOfNSSep > 0)
+ {
+ String prefix = name.substring(0, indexOfNSSep);
+ if(m_stylesheetRoot.getExcludeResultPrefixes().contains(prefix))
+ {
+ name = name.substring(indexOfNSSep+1);
+ }
+ }
+ return name;
+ }
+
/**
* Flush the pending element.
@@ -4017,6 +4035,7 @@
public void startElement (String name, AttributeList atts)
throws SAXException
{
+ name = excludePrefix(name);
flushPending();
int nAtts = atts.getLength();
m_pendingAttributes.clear();
@@ -4036,6 +4055,7 @@
public void endElement (String name)
throws SAXException
{
+ name = excludePrefix(name);
flushPending();
m_flistener.endElement(name);
if(null != m_traceListeners)