You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@xalan.apache.org by Christoph Reck <Ch...@dlr.de> on 2000/12/01 17:51:32 UTC
Re: Xalan-J 2 bug: Node.isSupported, XPath:position(),
serializer.OutputFormat
Here the sample XML and XSL code for the bugs mentioned below:
----------- output of SimpleTransform of xalan_1_1_D01 --------------
First the list with apply template:
1 TEST Test entry
NEWLINE 2 DLR Deutsches Zentrum fuer Luft- und Raumfahrt
NEWLINE 3 ESA European Space Agency
NEWLINE 4 Eurimage
Next the same list but with for-each:1 TEST Test entry
NEWLINE 2 DLR Deutsches Zentrum fuer Luft- und Raumfahrt
NEWLINE 3 ESA European Space Agency
NEWLINE 4 Eurimage
And again the list with apply template:1 TEST Test entry
NEWLINE 2 DLR Deutsches Zentrum fuer Luft- und Raumfahrt
NEWLINE 3 ESA European Space Agency
NEWLINE 4 Eurimagecat: cannot open foo.out
------------- end of SimpleTransform of xalan_1_1_D01 ---------------
----------- output of SimpleTransform of xalan-j_2_0_D01 --------------
First the list with apply template:
1 TEST Test entry
NEWLINE 2 DLR Deutsches Zentrum fuer Luft- und Raumfahrt
NEWLINE 3 ESA European Space Agency
NEWLINE 4 Eurimage
Next the same list but with for-each:
NEWLINE 5 TEST Test entry
NEWLINE 6 DLR Deutsches Zentrum fuer Luft- und Raumfahrt
NEWLINE 7 ESA European Space Agency
NEWLINE 8 Eurimage
And again the list with apply template:
NEWLINE 5 TEST Test entry
NEWLINE 6 DLR Deutsches Zentrum fuer Luft- und Raumfahrt
NEWLINE 7 ESA European Space Agency
NEWLINE 8 Eurimage
------------- end of SimpleTransform of xalan-j_2_0_D01 ---------------
Note the extra NEWLINE at the begining of the latter two blocks
and the erroneous numbering.
------------------------ foo.xml ----------------------------
<GIP>
<ServiceFacility>G</ServiceFacility>
<ServiceFunction>U</ServiceFunction>
<SessionId>*</SessionId>
<ProgressiveNumber>*</ProgressiveNumber>
<GipResultCode>_</GipResultCode>
<TargetService Provider="ESA" Facility="EECF" CollectionId="?" />
<UpdateStamp ResponsibleForUpdate="TEST" IdentifierForUpdate="000"
ReasonForUpdate="MUIS-C Test" />
<SubFunction>A</SubFunction>
<AttributeValueDescriptor>
<LastUpdate>2000-01-24 18:00:00.00</LastUpdate>
<AttributeId>DPRO</AttributeId>
<AttributeValue>TEST</AttributeValue>
<Provider>TEST</Provider>
<ShortCode>TEST</ShortCode>
<ShortName>TEST</ShortName>
<LongName>Test entry</LongName>
<Abstract>?</Abstract>
<DocumentReference />
</AttributeValueDescriptor>
<AttributeValueDescriptor>
<LastUpdate>2000-01-24 18:00:00.00</LastUpdate>
<AttributeId>DPRO</AttributeId>
<AttributeValue>DLR</AttributeValue>
<Provider>DLR</Provider>
<ShortCode>DLR</ShortCode>
<ShortName>DLR</ShortName>
<LongName>Deutsches Zentrum fuer Luft- und Raumfahrt</LongName>
<Abstract>?</Abstract>
<DocumentReference DocumentPointer="http://isis.dlr.de"
DocumentDescription="DLR Description" />
</AttributeValueDescriptor>
<AttributeValueDescriptor>
<LastUpdate>2000-01-24 18:00:00.00</LastUpdate>
<AttributeId>DPRO</AttributeId>
<AttributeValue>ESA</AttributeValue>
<Provider>ESA</Provider>
<ShortCode>ESA</ShortCode>
<ShortName>ESA</ShortName>
<LongName>European Space Agency</LongName>
<Abstract>?</Abstract>
<DocumentReference DocumentPointer="http://www.esa.int"
DocumentDescription="ESA Description" />
</AttributeValueDescriptor>
<AttributeValueDescriptor>
<LastUpdate>2000-01-24 18:00:00.00</LastUpdate>
<AttributeId>DPRO</AttributeId>
<AttributeValue>Eurimage</AttributeValue>
<Provider>Eurimage</Provider>
<ShortCode>Eurimage</ShortCode>
<ShortName>Eurimage</ShortName>
<LongName>Eurimage</LongName>
<Abstract>?</Abstract>
<DocumentReference />
</AttributeValueDescriptor>
<AttributeValueDescriptor>
<LastUpdate>2000-11-07T09:58</LastUpdate>
<AttributeId>*AID</AttributeId>
<AttributeValue>DPRO</AttributeValue>
<ShortName>Provider</ShortName>
</AttributeValueDescriptor>
<AttributeValueDescriptor>
<LastUpdate>2000-11-07T09:58</LastUpdate>
<AttributeId>*AID</AttributeId>
<AttributeValue>DFAC</AttributeValue>
<ShortName>Facility</ShortName>
</AttributeValueDescriptor>
</GIP>
-------------------- end of foo.xml -------------------------
------------------------ foo.xsl ----------------------------
<?xml version="1.0"?>
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="text" />
<!-- example extract to format valids -->
<xsl:template match="*" >
<xsl:variable name="list" select="AttributeValueDescriptor[AttributeId='DPRO']" />
<xsl:text>
First the list with apply template:
</xsl:text>
<xsl:apply-templates select="$list" mode="called" />
<xsl:text>
Next the same list but with for-each:</xsl:text>
<xsl:for-each select="$list">
<!-- ### the first entry should not emit a new line -->
<xsl:if test="position() != 1"><xsl:text>
NEWLINE </xsl:text>
</xsl:if>
<!-- ### this is emitting wrong number in XalanJ2 (it seems to be the output position) -->
<xsl:value-of select="position()" />
<xsl:text> </xsl:text><xsl:value-of select="ShortName" />
<xsl:if test="ShortName != LongName">
<xsl:text> </xsl:text><xsl:value-of select="LongName" />
</xsl:if>
</xsl:for-each>
<xsl:text>
And again the list with apply template:</xsl:text>
<xsl:apply-templates select="$list" mode="called" />
</xsl:template>
<xsl:template match="AttributeValueDescriptor" mode="called" >
<!-- ### the first entry should not emit a new line -->
<xsl:if test="position() != 1"><xsl:text>
NEWLINE </xsl:text>
</xsl:if>
<!-- ### this is emitting wrong number in XalanJ2 -->
<xsl:value-of select="position()" />
<xsl:text> </xsl:text><xsl:value-of select="ShortName" />
<xsl:if test="ShortName != LongName">
<xsl:text> </xsl:text><xsl:value-of select="LongName" />
</xsl:if>
</xsl:template>
</xsl:stylesheet>
-------------------- end of foo.xsl -------------------------
Gary L Peskin wrote:
>
> Christoph Reck wrote:
> >
> > Hi,
> >
> > going from Xalan 1.1_D01 to Xalan 2.0_D01 I found the following
> > problems:
> >
> > 1. The org.w3c.Node included in Xalan defines a method supports(),
> > whereas the W3C standard is defining isSupported() for DOM2.
> > This causes problems e.g. in xpath.axes.ChildWalkerOneStep.nextNode()
> > emitting a AbstractMethodException when the xerces_1.2.X.jar is
> > before the xalan.jar.
>
> You need to use the version of xerces.jar that comes with Xalan. Xalan
> 1.1_D01 is an older Xalan version and requires the old Xerces. Xalan 2.0
> requires the new Xerces. This has been fixed in the latest builds of
> both versions of Xalan so that you should be able to use the latest
> version of Xerces with the latest versions of both XalanJ 1 and XalanJ
> 2.
I am using the xerces.jar within xalan-j_2_0_D01. Pasing the CVSWEB
of xalan-j_2_0_D02, this seems to be fixed (The 2_0_D02 version does
not seem to be yet downloadable?).
>
> > 2. The position() function in XPath is returning relative positions.
> > When doing an apply-templates on a selected subset, the first
> > element in the template match is not 1 as it was in the earlyer
> > Xalan implementation. I have found no workaround for this:
> > <xsl:if test="position > 1"><br/></xsl:if>
> > to separate continuation lines for each other.
> >
> > It seems that Xalan2 does not make a copy, but select... returns a
> > NodeList referencing the original nodes and their position is
> > then relative to the source and not to the select.
>
> Can you please provide a sample XML and XSL and I'll see if it causes a
> problem with the latest version of Xalan 2?
see examples above.
>
> > 3. org.apache.xml.serializer.OutputFormat does not respect the
> > setOmitXMLDeclaration(true) flag. Previous xerces version
> > did not emit the doctype declaration, the new xerces.jar does
> > emit it (this is really a xerces bug).
>
> This may also be fixed in the latest version of Xerces. Can you provide
> sample XML and XSL?
Note that if the XSL contains <xsl:output method="text" />,
it does not emit anything, but without it xalan-j_2_0_D01 emits
the <?xml ...> directive.
-------------------- code to format the output -------------------
/**
* Format XML indented nicely.
*
* @param xml The XML node to pretty print.
* @return A string with the XML prettely formatted.
*/
public String format(Node xml, int indent, String indentOffset)
{
OutputFormat fmt = new OutputFormat();
fmt.setIndent(indent);
fmt.setLineSeparator("\n" + indentOffset);
fmt.setOmitXMLDeclaration(true);
ByteArrayOutputStream buf = new ByteArrayOutputStream();
HTMLSerializer serializer = new HTMLSerializer(buf, fmt);
try {
if (xml instanceof Element)
serializer.serialize( (Element) xml );
else if (xml instanceof Document)
serializer.serialize( ((Document) xml).getDocumentElement() );
else
serializer.serialize( xml.getOwnerDocument() );
} catch (Exception ex) {
// ignore
}
return buf.toString();
}
------------------ end of code to format the output -----------------
>
> Gary
:) Christoph
Re: Xalan-J 2 bug: Node.isSupported, XPath:position(),
serializer.OutputFormat
Posted by Gary L Peskin <ga...@firstech.com>.
Christoph Reck wrote:
>
> Here the sample XML and XSL code for the bugs mentioned below:
Chris --
I just tried this with the current version of XalanJ2 built from CVS and
I get exactly the same output that you get from XalanJ1. There was a
bug with position() which was fixed a while back but after XalanJ
2.0.D01 and I think that that's what was causing your problem.
Scott has said that a new alpha version of XalanJ2 should be out soon.
In the meantime, you'll need to do a build from the CVS source.
Gary