You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@xalan.apache.org by Frank Griffin <ft...@ntplx.net> on 2001/01/29 20:27:55 UTC

Newbie needs help....

I'm getting an internal error from Xalan that I don't understand:

[D:\xsl]java -classpath d:\xerces\xalan.jar;d:\xerces\xerces.jar org.apache.xalan.xslt.Process -in test.xml -xsl testhtml.xsl -out test.html -v
>>>>>>> Xalan Version 2.0_D07, <<<<<<<
file:///D:/xsl/testhtml.xsl; Line 34; Column 33
Parser error: Can not convert #RTREEFRAG to a NodeList!

The example won't make a lot of sense, since it is culled from a much larger one, but it reproduces the problem.  Maybe my problem is that the larger one doesn't make sense either.  What I'm trying to do is define a report output language and a transform which will produce HTML from it.  The input document has two sections.  The first is a collection of "xstyle" elements which describe visual formatting options in a non-HTML-specific way (so that other non-HTML transforms can be written to use the same document).  The second is the report data elements, where each element has a "ystyle" attribute which can name a specific xstyle that should govern its formatting.  I hit this problem trying to come up with a variable ($ElementStyle) which returns a string of HTML formatting information using values from the ystyle associated with the current node.   The xsl:key approach is just the latest in a series of trial and error attempts to make this work; if this approach is less than optimium, any suggestions would be appreciated.

Here are the files.  I'll attach them as well, in case some mailreaders mess up the inline ones.  Thanks in advance for any help you can provide.

test.xsd
---------

<?xml version="1.0" encoding="UTF-8"?>
<schema>

 <element name="list">
  <complexType>
   <element ref="styles" minOccurs='0' maxOccurs='1'/>
   <element ref="headerField" minOccurs='0' maxOccurs='unbounded'/>
  </complexType>
 </element>

 <element name="styles">
  <complexType>
   <element ref="xstyle" minOccurs='0' maxOccurs='unbounded'/>
  </complexType>
 </element>

 <element name="xstyle">
  <complexType>
   <attribute name="id" type="string"/>
   <attribute name="foreground" type="string"/>
  </complexType>
 </element>

 <element name="headerField" type="string">
   <attribute name="ystyle" type="xstyle"/>
 </element>

</schema>


test.xml:
----------

<?xml version="1.0" encoding="UTF-8"?>
<list xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance"
      xsi:noNamespaceSchemaLocation='list.xsd'>

<styles>
 <xstyle id="headersStyle"
         foreground="white"/>
</styles>

<headerField ystyle="headersStyle">
 Family Name
</headerField>

</list>

testhtml.xsl
-------------

<?xml version="1.0"?>
<xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
               version="1.0">

  <xsl:output method="html" omit-xml-declaration="yes"/>

  <xsl:key name="zstyle" match="xstyle" use="@id"/>

  <xsl:variable name="StyleKey">
    key("'zstyle'","{@ystyle}")
  </xsl:variable>

  <xsl:variable name="ElementStyle">
    color: <xsl:value-of select="$StyleKey/@foreground"/>;
  </xsl:variable>

  <xsl:template match="/">
    <HTML>
      <BODY>
        <xsl:apply-templates select="list"/>
      </BODY>
    </HTML>
  </xsl:template>

  <xsl:template match="list">
    <TABLE>
     <TR>
      <xsl:apply-templates select="headerField"/>
     </TR>
    </TABLE>
  </xsl:template>

  <xsl:template match="headerField">
    <TH STYLE="{$ElementStyle}">
      <xsl:value-of select="."/>
    </TH>
  </xsl:template>

</xsl:transform>

Posted by Edierley Messias <ed...@dcc.ufmg.br>.
Hi people,
There is a error when I apply the transformation to a XSL that have a
<xsl:output doctype-public="?"> declaration in a Servlet program.

My final document must have the 
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML1.1//EN"
"http://www.wapforum.org/DTD/wml_1.1.xml">

And XALAN/Xerces changes the the <!DOCTYPE> to the comment version of the
respective DTD in http://www.wapforum.org/DTD/wml_1.1.xml

Then I wrote the XSL with
<xsl:output method="xml"
  indent="yes"
  omit-xml-declaration="no"
  doctype-public="-//WAPFORUM//DTD WML 1.1//EN"
  doctype-system="http://www.wapforum.com/DTD/wml_1.1.xml"
/>

My Servlet is OK, when I apply the WML page to a xsl without the
<xsl:output method="?"> the transformation works, but the page cannot be
appear in the mobile-browser withou the <!DOCTYPE> declaration.
The page look like:
<?xml version="1.0"?>
<!--DTD commented-->
<wml>
 wml-stuff
</wml>

When I run the Servlet with the <xsl:output> file, the server gives me
"500 Internal Server Error".

I looked at jserv.log file and a found this (WapServlet is my servlet):
[29/01/2001 17:39:30:146 GMT-02:00] java.lang.NullPointerException
	at org.apache.xalan.xslt.StylesheetRoot.makeSAXSerializer(StylesheetRoot.java:518)
	at org.apache.xalan.xslt.StylesheetRoot.process(StylesheetRoot.java:380)
	at org.apache.xalan.xslt.XSLTEngineImpl.process(XSLTEngineImpl.java:679)
	at WapServlet.doGetHTTP(WapServlet.java:72)
	at WapServlet.service(WapServlet.java:46)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:309)
	at org.apache.jserv.JServConnection.processRequest(JServConnection.java:314)
	at org.apache.jserv.JServConnection.run(JServConnection.java:188)
	at java.lang.Thread.run(Thread.java:484)

What is the problem? There is a bug in StylesheetRoot or XSLTEngineImpl?

The program below works fine with the <xsl:output> file.

public class SimpleWML{
    public static void main() ...{
        XSLTProcessor processor = XSLTProcessorFactory.getProcessor();
        processor.process(new XSLTInputSource("i.wml"), new XSLTInputSource("text7.xsl"), new XSLTResultTarget(System.out));
    }
}

And also the command line:
"java org.apache.xalan.xslt.Process -in i.wml -xsl text7.xsl"


Please, do you know what is going on?

Edierley Messias.



Re: Newbie needs help....

Posted by Frank Griffin <ft...@ntplx.net>.
I just noticed that test.xml is naming list.xsd as its schema (list was the larger case).  This should be changed to test.xsd.  The same failure occurs with the correction.