You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@xalan.apache.org by Telin Yang <ty...@mobilocity.net> on 2000/06/23 01:04:04 UTC
Newbie questions
Hi,
Applogize if this is not a list to ask more user oriented questions. But I
can't find a list is geared toward how to use xalan.
I am trying to put together a demo web page viewable from different
browsers - IE, Netscape, WAP phone using the exact same URL, such as
http://mysite/servlet/DefaultApplyXSL/foo.xml. As you can see I am using the
DefaultApplyXSL that come with xalan dist. So far I am successfully using
DefaultApplyXSL if I supply the stylesheet in the URL like
http://mysite/servlet/DefaultApplyXSL/foo.xml?xslURL=/foo.xsl but I am stuck
in error 500 whenever I am not supply stylesheet.
Following are the xml and stylesheets
+++++++++++++++++++++++++
foo.xml
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" media="netscape" href="foo.xsl"?>
<?xml-stylesheet type="text/xsl" media="explorer" href="foo2.xsl"?>
<doc>Hello</doc>
foo.xsl
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:output method="html" indent="yes"/>
<xsl:template match="/">
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="doc">
<html>
<head><title><xsl:value-of select="@title"/></title></head>
<body bgcolor="#ffffff" text="#000000">
<out><xsl:value-of select="."/></out>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
foo2.xsl
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:output method="html" indent="yes"/>
<xsl:template match="/">
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="doc">
<html>
<head><title><xsl:value-of select="@title"/></title></head>
<body bgcolor="#aaaaaa" text="#000000">
<out><xsl:value-of select="."/></out>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
++++++++++++++++++++++++++++++
I use IIS for http server and an ISAPI servlet engine called ServletExec.
After several try with no success, I modified DefaultApplyXSL to generate
more output so I can know where it failed. Following is the code fragment I
belive is the problem
+++++++++++++++++++++
public static String getXSLURLfromDoc(XSLTInputSource xmlSource, String
attributeName, String attributeValue, ApplyXSLListener listener)
{
String tempURL = null, returnURL = null;
listener.out.println("step 0.0");
Node pin = xmlSource.getNode(); <------- can not get DOM node!!
listener.out.println("step 0.1");
listener.out.println(pin.getNodeName()); <----- pin is null here
NodeList children = pin.getChildNodes();
listener.out.println("step1");
int nNodes = children.getLength(), i;
listener.out.println("step2");
for(i = 0; i < nNodes; i++)
{
.......
+++++++++++++++++++++++++
And following is the error msg shows on browser
+++++++++++++++++++
The following error occurred: 500 -
getStylesheet() resulted in ApplyXSLException
Parsing XML Document from PathInfo: /foo.xml
Mozilla/4.72 [en] (Windows NT 5.0; I)-->netscape
step 0.0
step 0.1
java.lang.NullPointerException:
at DefaultApplyXSL.getXSLURLfromDoc(DefaultApplyXSL.java:456)
at DefaultApplyXSL.getStylesheet(DefaultApplyXSL.java:539)
at ApplyXSL.process(ApplyXSL.java:305)
at ApplyXSL.doGet(ApplyXSL.java:245)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:865)
at
newatlanta.servletexec.ServletExec.CallServletService(ServletExec.java)
at
newatlanta.servletexec.ServletExec.processServletRequest(ServletExec.java)
at
newatlanta.servletexec.ServletExec.ProcessRequest(ServletExec.java)
at
newatlanta.servletexec.ServletExec.ProcessRequest(ServletExec.java)
++++++++++++++++
Sorry for the long mail. I am really lost here. Hope someone can point me
where I messed up or how to find the real problem.
Thanks.