You are viewing a plain text version of this content. The canonical link for it is here.
Posted to xang-dev@xml.apache.org by Andy Glick <an...@home.com> on 2000/09/21 01:20:41 UTC

problem with get() from system.script.xml looks to be...

Mike,

In this incarnation of the problem there appears to be some bad html
characters generated in the get() method.  The script is now being 
dumped to the browser window with the stack traces.  I've include all 
of the output.

Look for this chunk of code in the get method.

----------------------------------------------------------------------
        // require a trailing slash.
        var path;
        path = context.getRequest().getPathInfo();
<b>     if (path.charAt(path.length-1) != '/')
</b>    {
                app.redirectTo(context,path+&quot;/&quot;);
                return;
        }
-----------------------------------------------------------------------

Any ideas?

-a



<html><body><h2>System error</h2>Error in handler for
'onGet'<pre>Runtime error Conversion to object unsupported by null
detected at line 117 of function 'get' in string starting with:
'get();'...
called at line 1 in string starting with:
'get();'...</pre></body></html><!--
FESI.jslib.JSException: Runtime error Conversion to object unsupported
by null
detected at line 117 of function 'get' in string starting with:
'get();'...
called at line 1 in string starting with: 'get();'...
FESI.jslib.JSException: Runtime error Conversion to object unsupported
by null
detected at line 117 of function 'get' in string starting with:
'get();'...
called at line 1 in string starting with: 'get();'...
        at FESI.Data.JSWrapper.evalAsFunction(JSWrapper.java)
        at
org.apache.xang.scriptEngine.FesiEngine.run(FesiEngine.java:108)
        at
org.apache.xang.net.http.object.impl.HTTPScriptedObject.dispatchToScript(HTTPScriptedObject.java:198)
        at
org.apache.xang.net.http.object.impl.HTTPScriptedObject.dispatch(HTTPScriptedObject.java:144)
        at
org.apache.xang.net.http.object.impl.HTTPRequestHandler.service(HTTPRequestHandler.java:293)
        at
org.apache.xang.net.http.object.impl.HTTPRequestHandler.service(HTTPRequestHandler.java:242)
        at
org.apache.xang.net.http.object.impl.HTTPObjectServer.service(HTTPObjectServer.java:144)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
        at
org.apache.tomcat.core.ServletWrapper.handleRequest(ServletWrapper.java:503)
        at
org.apache.tomcat.core.ContextManager.service(ContextManager.java:559)
        at
org.apache.tomcat.service.http.HttpConnectionHandler.processConnection(HttpConnectionHandler.java:160)
        at
org.apache.tomcat.service.TcpConnectionThread.run(SimpleTcpEndpoint.java:338)
        at java.lang.Thread.run(Unknown Source)
due to:
FESI.Exceptions.EcmaScriptException: Runtime error Conversion to object
unsupported by null
detected at line 117 of function 'get' in string starting with:
'get();'...
called at line 1 in string starting with: 'get();'...
FESI.Exceptions.EcmaScriptException: Runtime error Conversion to object
unsupported by null
detected at line 117 of function 'get' in string starting with:
'get();'...
called at line 1 in string starting with: 'get();'...
        at FESI.Data.ESValue.toESObject(ESValue.java)
        at
FESI.Interpreter.EcmaScriptEvaluateVisitor.visit(EcmaScriptEvaluateVisitor.java)
        at
FESI.AST.ASTCompositeReference.jjtAccept(ASTCompositeReference.java)
        at
FESI.Interpreter.EcmaScriptEvaluateVisitor.visit(EcmaScriptEvaluateVisitor.java)
        at
FESI.AST.ASTBinaryExpressionSequence.jjtAccept(ASTBinaryExpressionSequence.java)
        at
FESI.Interpreter.EcmaScriptEvaluateVisitor.visit(EcmaScriptEvaluateVisitor.java)
        at
FESI.AST.ASTFunctionCallParameters.jjtAccept(ASTFunctionCallParameters.java)
        at
FESI.Interpreter.EcmaScriptEvaluateVisitor.visit(EcmaScriptEvaluateVisitor.java)
        at
FESI.AST.ASTCompositeReference.jjtAccept(ASTCompositeReference.java)
        at
FESI.Interpreter.EcmaScriptEvaluateVisitor.visit(EcmaScriptEvaluateVisitor.java)
        at
FESI.AST.ASTBinaryExpressionSequence.jjtAccept(ASTBinaryExpressionSequence.java)
        at
FESI.Interpreter.EcmaScriptEvaluateVisitor.visit(EcmaScriptEvaluateVisitor.java)
        at FESI.AST.ASTIfStatement.jjtAccept(ASTIfStatement.java)
        at
FESI.Interpreter.EcmaScriptEvaluateVisitor.visit(EcmaScriptEvaluateVisitor.java)
        at FESI.AST.ASTStatement.jjtAccept(ASTStatement.java)
        at
FESI.Interpreter.EcmaScriptEvaluateVisitor.visit(EcmaScriptEvaluateVisitor.java)
        at FESI.AST.ASTStatementList.jjtAccept(ASTStatementList.java)
        at
FESI.Interpreter.EcmaScriptEvaluateVisitor.evaluateFunction(EcmaScriptEvaluateVisitor.java)
        at FESI.Interpreter.Evaluator.evaluateFunction(Evaluator.java)
        at
FESI.Data.ConstructedFunctionObject.callFunction(ConstructedFunctionObject.java)
        at FESI.Data.ESObject.doIndirectCallInScope(ESObject.java)
        at FESI.Interpreter.ScopeChain.doIndirectCall(ScopeChain.java)
        at FESI.Interpreter.Evaluator.doIndirectCall(Evaluator.java)
        at
FESI.Interpreter.EcmaScriptEvaluateVisitor.visit(EcmaScriptEvaluateVisitor.java)
        at
FESI.AST.ASTCompositeReference.jjtAccept(ASTCompositeReference.java)
        at
FESI.Interpreter.EcmaScriptEvaluateVisitor.visit(EcmaScriptEvaluateVisitor.java)
        at FESI.AST.ASTStatement.jjtAccept(ASTStatement.java)
        at
FESI.Interpreter.EcmaScriptEvaluateVisitor.visit(EcmaScriptEvaluateVisitor.java)
        at FESI.AST.ASTProgram.jjtAccept(ASTProgram.java)
        at
FESI.Interpreter.EcmaScriptEvaluateVisitor.evaluateProgram(EcmaScriptEvaluateVisitor.java)
        at FESI.Interpreter.Evaluator.evaluate(Evaluator.java)
        at FESI.Interpreter.Evaluator.evaluate(Evaluator.java)
        at FESI.Interpreter.Evaluator.evaluate(Evaluator.java)
        at FESI.Data.JSWrapper.evalAsFunction(JSWrapper.java)
        at
org.apache.xang.scriptEngine.FesiEngine.run(FesiEngine.java:108)
        at
org.apache.xang.net.http.object.impl.HTTPScriptedObject.dispatchToScript(HTTPScriptedObject.java:198)
        at
org.apache.xang.net.http.object.impl.HTTPScriptedObject.dispatch(HTTPScriptedObject.java:144)
        at
org.apache.xang.net.http.object.impl.HTTPRequestHandler.service(HTTPRequestHandler.java:293)
        at
org.apache.xang.net.http.object.impl.HTTPRequestHandler.service(HTTPRequestHandler.java:242)
        at
org.apache.xang.net.http.object.impl.HTTPObjectServer.service(HTTPObjectServer.java:144)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
        at
org.apache.tomcat.core.ServletWrapper.handleRequest(ServletWrapper.java:503)
        at
org.apache.tomcat.core.ContextManager.service(ContextManager.java:559)
        at
org.apache.tomcat.service.http.HttpConnectionHandler.processConnection(HttpConnectionHandler.java:160)
        at
org.apache.tomcat.service.TcpConnectionThread.run(SimpleTcpEndpoint.java:338)
        at java.lang.Thread.run(Unknown Source)

--><pre>



/** Base browser method. Override to provide object specific
functionality.
*/
function doObjectEdit(context,returnTypes,parameters)
{
        parameters.put(&quot;layout&quot;,&quot;editor.xsl&quot;);
        get(context,returnTypes,parameters);
}

function doObjectBrowser(context,returnTypes,parameters)
{
       
parameters.put(&quot;layout&quot;,&quot;editor_browse.xsl&quot;);
        get(context,returnTypes,parameters);
}

/** Base editor method. Override to provide object specific
functionality.
*/
function doObjectEditor(context,returnTypes,parameters)
{
        parameters.put(&quot;layout&quot;,&quot;editor_edit.xsl&quot;);
        get(context,returnTypes,parameters);
}

/** Base update method
*/
function doObjectUpdate(context,returnTypes,parameters)
{
        doc = context.getResponse().getWriter();
        for (prop in parameters.keys())
        {
                if (prop.indexOf('prop_') == 0)
                {
                        value = parameters.get(prop);
                        attrib = prop.substring(5);
                        if (value == null || value==&quot;&quot;)
                        {
                                xml.removeAttribute(attrib);
                        }
                        else
                        {
                                xml.setAttribute(attrib,value);
                        }
                        
                }
        }

        context.getResponse().setContentType(&quot;text/html&quot;);
       
doc.println(&quot;&lt;html&gt;&lt;body&gt;OK&lt;/body&gt;&lt;/html&gt;&quot;);
}

function doObjectAddProp(context,returnTypes,parameters)
{
        name = parameters.get('name');
        value = parameters.get('value');
        xml.setAttribute(name,value);
        
        context.getResponse().setContentType(&quot;text/html&quot;);
        doc = context.getResponse().getWriter();
       
doc.println(&quot;&lt;html&gt;&lt;body&gt;&quot;+name+&quot;=&quot;+value+&quot;&lt;/body&gt;&lt;/html&gt;&quot;);
}





function debug(s)
{
        Packages.java.lang.System.out.println(s);
}

function getInheritedAttribute(element,name)
{
        var value;
        value=null;
        
        while ((element != null) &amp;&amp; (element.getNodeType() ==
1))
        {
                value = element.getAttribute(name);
                if (value != null &amp;&amp; value != &quot;&quot;)
                        break;

                element = element.getParentNode();
        }
        return value;
}

function getLayout(element)
{
        return getInheritedAttribute(element,'layout');
}

/**
* This determines which XSL stylesheet to use and applies the stylesheet
to the targeted
* element.
*/
function get(context,returnTypes,parameters)
{
        var doc;
        var layout;

        debug('in get()');
        doc = context.getResponse().getWriter();

        // check for object
        if (xml == null)
        {
                context.getResponse().sendError(404,&quot;Page not
found.&quot;);
                return;
        }
        
        // require a trailing slash.
        var path;
        path = context.getRequest().getPathInfo();
<b>     if (path.charAt(path.length-1) != '/')
</b>    {
                app.redirectTo(context,path+&quot;/&quot;);
                return;
        }
        
        // get the url to the XSL to use for the transform.
        base = getInheritedAttribute(xml,'resources.server');

        layout = parameters.get('layout');
        if (layout == null)
        {
                layout = getLayout(xml);
        }

        if (base != null &amp;&amp; (layout.indexOf(':') &lt;= 1))
        {
                media_root =
Packages.org.apache.xang.util.ServletUtil.getRealPath(context);
                layout = media_root + &quot;/&quot; + base + layout;
                layout =
&quot;file:///&quot;+Packages.org.apache.xang.util.ServletUtil.resolveURL(layout);
        }

        if (layout != null)
        {
               
context.getResponse().setContentType(&quot;text/html&quot;);
                // do XSL via Xalan
                {
                        processor =
Packages.org.apache.xalan.xslt.XSLTProcessorFactory.getProcessorUsingLiaisonName(&quot;org.apache.xalan.xpath.xdom.XercesLiaison&quot;);
                        
                        source = new
Packages.org.apache.xalan.xslt.XSLTInputSource();
                        source.setNode(xml);
                        
                        stylesheet = new
Packages.org.apache.xalan.xslt.XSLTInputSource();
                        stylesheet.setSystemId(layout);
                        
                        output = new
Packages.org.apache.xalan.xslt.XSLTResultTarget();
                        output.setCharacterStream(doc);
                        
                        processor.process(source,stylesheet,output);
                }
                
                doc.flush();
        }
}

function getXML(context,returnTypes,parameters)
{
        doc = context.getResponse().getWriter();
        doc.println(&quot;&lt;?xml version='1.0' ?&gt;&quot;);
        doc.println(&quot;&lt;!-- cool huh? --&gt;&quot;);
        doc.println(xml.getXML());
}

function getScript(context,returnTypes,parameters)
{
        var doc;
        var s;
        var util;

        doc = context.getResponse().getWriter();

        util = new Packages.org.apache.xang.util.TextUtil();
        

        s = &quot;&lt;html&gt;&lt;body&gt;&lt;pre&gt;&quot;;
        s += util.encodeToHTML(app.loadScript(null));
        s += &quot;&lt;/pre&gt;&lt;/body&gt;&lt;/html&gt;&quot;;
        doc.println(s);
        doc.flush();
}
        

</pre>

RE: problem with get() from system.script.xml looks to be...

Posted by "S. Mike Dierken" <mi...@KnowNow.com>.
Andy,
It looks as though the execution of the JavaScript statement highlighted
(between the <b> tags) is causing problems.

The text "if (path.charAt(path.length-1) != '/')" will cause problems if the
path variable is null.
Try changing the code in the system.script.xml to check for a null return
from the call to getPathInfo().

If this is the case, then Tomcat seems be doing different things than JServ.
Which would suck, because then I'll have to install yet another servlet
engine and work with it.

I have to leave right now, but I'll check for your response first thing in
the morning!

Mike

> -----Original Message-----
> From: Andy Glick [mailto:andyglick@home.com]
> Sent: Wednesday, September 20, 2000 4:21 PM
> To: xang devel
> Subject: problem with get() from system.script.xml looks to be...
>
>
> Mike,
>
> In this incarnation of the problem there appears to be some bad html
> characters generated in the get() method.  The script is now being
> dumped to the browser window with the stack traces.  I've include all
> of the output.
>
> Look for this chunk of code in the get method.
>
> ----------------------------------------------------------------------
>         // require a trailing slash.
>         var path;
>         path = context.getRequest().getPathInfo();
> <b>     if (path.charAt(path.length-1) != '/')
> </b>    {
>                 app.redirectTo(context,path+&quot;/&quot;);
>                 return;
>         }
> -----------------------------------------------------------------------
>
> Any ideas?
>
> -a
>
>
>
> <html><body><h2>System error</h2>Error in handler for
> 'onGet'<pre>Runtime error Conversion to object unsupported by null
> detected at line 117 of function 'get' in string starting with:
> 'get();'...
> called at line 1 in string starting with:
> 'get();'...</pre></body></html><!--
> FESI.jslib.JSException: Runtime error Conversion to object unsupported
> by null
> detected at line 117 of function 'get' in string starting with:
> 'get();'...
> called at line 1 in string starting with: 'get();'...
> FESI.jslib.JSException: Runtime error Conversion to object unsupported
> by null
> detected at line 117 of function 'get' in string starting with:
> 'get();'...
> called at line 1 in string starting with: 'get();'...
>         at FESI.Data.JSWrapper.evalAsFunction(JSWrapper.java)
>         at
> org.apache.xang.scriptEngine.FesiEngine.run(FesiEngine.java:108)
>         at
> org.apache.xang.net.http.object.impl.HTTPScriptedObject.dispatchTo
> Script(HTTPScriptedObject.java:198)
>         at
> org.apache.xang.net.http.object.impl.HTTPScriptedObject.dispatch(H
> TTPScriptedObject.java:144)
>         at
> org.apache.xang.net.http.object.impl.HTTPRequestHandler.service(HT
> TPRequestHandler.java:293)
>         at
> org.apache.xang.net.http.object.impl.HTTPRequestHandler.service(HT
> TPRequestHandler.java:242)
>         at
> org.apache.xang.net.http.object.impl.HTTPObjectServer.service(HTTP
> ObjectServer.java:144)
>         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
>         at
> org.apache.tomcat.core.ServletWrapper.handleRequest(ServletWrapper
> .java:503)
>         at
> org.apache.tomcat.core.ContextManager.service(ContextManager.java:559)
>         at
> org.apache.tomcat.service.http.HttpConnectionHandler.processConnec
> tion(HttpConnectionHandler.java:160)
>         at
> org.apache.tomcat.service.TcpConnectionThread.run(SimpleTcpEndpoin
> t.java:338)
>         at java.lang.Thread.run(Unknown Source)
> due to:
> FESI.Exceptions.EcmaScriptException: Runtime error Conversion to object
> unsupported by null
> detected at line 117 of function 'get' in string starting with:
> 'get();'...
> called at line 1 in string starting with: 'get();'...
> FESI.Exceptions.EcmaScriptException: Runtime error Conversion to object
> unsupported by null
> detected at line 117 of function 'get' in string starting with:
> 'get();'...
> called at line 1 in string starting with: 'get();'...
>         at FESI.Data.ESValue.toESObject(ESValue.java)
>         at
> FESI.Interpreter.EcmaScriptEvaluateVisitor.visit(EcmaScriptEvaluat
> eVisitor.java)
>         at
> FESI.AST.ASTCompositeReference.jjtAccept(ASTCompositeReference.java)
>         at
> FESI.Interpreter.EcmaScriptEvaluateVisitor.visit(EcmaScriptEvaluat
> eVisitor.java)
>         at
> FESI.AST.ASTBinaryExpressionSequence.jjtAccept(ASTBinaryExpression
> Sequence.java)
>         at
> FESI.Interpreter.EcmaScriptEvaluateVisitor.visit(EcmaScriptEvaluat
> eVisitor.java)
>         at
> FESI.AST.ASTFunctionCallParameters.jjtAccept(ASTFunctionCallParame
> ters.java)
>         at
> FESI.Interpreter.EcmaScriptEvaluateVisitor.visit(EcmaScriptEvaluat
> eVisitor.java)
>         at
> FESI.AST.ASTCompositeReference.jjtAccept(ASTCompositeReference.java)
>         at
> FESI.Interpreter.EcmaScriptEvaluateVisitor.visit(EcmaScriptEvaluat
> eVisitor.java)
>         at
> FESI.AST.ASTBinaryExpressionSequence.jjtAccept(ASTBinaryExpression
> Sequence.java)
>         at
> FESI.Interpreter.EcmaScriptEvaluateVisitor.visit(EcmaScriptEvaluat
> eVisitor.java)
>         at FESI.AST.ASTIfStatement.jjtAccept(ASTIfStatement.java)
>         at
> FESI.Interpreter.EcmaScriptEvaluateVisitor.visit(EcmaScriptEvaluat
> eVisitor.java)
>         at FESI.AST.ASTStatement.jjtAccept(ASTStatement.java)
>         at
> FESI.Interpreter.EcmaScriptEvaluateVisitor.visit(EcmaScriptEvaluat
> eVisitor.java)
>         at FESI.AST.ASTStatementList.jjtAccept(ASTStatementList.java)
>         at
> FESI.Interpreter.EcmaScriptEvaluateVisitor.evaluateFunction(EcmaSc
> riptEvaluateVisitor.java)
>         at FESI.Interpreter.Evaluator.evaluateFunction(Evaluator.java)
>         at
> FESI.Data.ConstructedFunctionObject.callFunction(ConstructedFuncti
> onObject.java)
>         at FESI.Data.ESObject.doIndirectCallInScope(ESObject.java)
>         at FESI.Interpreter.ScopeChain.doIndirectCall(ScopeChain.java)
>         at FESI.Interpreter.Evaluator.doIndirectCall(Evaluator.java)
>         at
> FESI.Interpreter.EcmaScriptEvaluateVisitor.visit(EcmaScriptEvaluat
> eVisitor.java)
>         at
> FESI.AST.ASTCompositeReference.jjtAccept(ASTCompositeReference.java)
>         at
> FESI.Interpreter.EcmaScriptEvaluateVisitor.visit(EcmaScriptEvaluat
> eVisitor.java)
>         at FESI.AST.ASTStatement.jjtAccept(ASTStatement.java)
>         at
> FESI.Interpreter.EcmaScriptEvaluateVisitor.visit(EcmaScriptEvaluat
> eVisitor.java)
>         at FESI.AST.ASTProgram.jjtAccept(ASTProgram.java)
>         at
> FESI.Interpreter.EcmaScriptEvaluateVisitor.evaluateProgram(EcmaScr
> iptEvaluateVisitor.java)
>         at FESI.Interpreter.Evaluator.evaluate(Evaluator.java)
>         at FESI.Interpreter.Evaluator.evaluate(Evaluator.java)
>         at FESI.Interpreter.Evaluator.evaluate(Evaluator.java)
>         at FESI.Data.JSWrapper.evalAsFunction(JSWrapper.java)
>         at
> org.apache.xang.scriptEngine.FesiEngine.run(FesiEngine.java:108)
>         at
> org.apache.xang.net.http.object.impl.HTTPScriptedObject.dispatchTo
> Script(HTTPScriptedObject.java:198)
>         at
> org.apache.xang.net.http.object.impl.HTTPScriptedObject.dispatch(H
> TTPScriptedObject.java:144)
>         at
> org.apache.xang.net.http.object.impl.HTTPRequestHandler.service(HT
> TPRequestHandler.java:293)
>         at
> org.apache.xang.net.http.object.impl.HTTPRequestHandler.service(HT
> TPRequestHandler.java:242)
>         at
> org.apache.xang.net.http.object.impl.HTTPObjectServer.service(HTTP
> ObjectServer.java:144)
>         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
>         at
> org.apache.tomcat.core.ServletWrapper.handleRequest(ServletWrapper
> .java:503)
>         at
> org.apache.tomcat.core.ContextManager.service(ContextManager.java:559)
>         at
> org.apache.tomcat.service.http.HttpConnectionHandler.processConnec
> tion(HttpConnectionHandler.java:160)
>         at
> org.apache.tomcat.service.TcpConnectionThread.run(SimpleTcpEndpoin
> t.java:338)
>         at java.lang.Thread.run(Unknown Source)
>
> --><pre>
>
>
>
> /** Base browser method. Override to provide object specific
> functionality.
> */
> function doObjectEdit(context,returnTypes,parameters)
> {
>         parameters.put(&quot;layout&quot;,&quot;editor.xsl&quot;);
>         get(context,returnTypes,parameters);
> }
>
> function doObjectBrowser(context,returnTypes,parameters)
> {
>
> parameters.put(&quot;layout&quot;,&quot;editor_browse.xsl&quot;);
>         get(context,returnTypes,parameters);
> }
>
> /** Base editor method. Override to provide object specific
> functionality.
> */
> function doObjectEditor(context,returnTypes,parameters)
> {
>         parameters.put(&quot;layout&quot;,&quot;editor_edit.xsl&quot;);
>         get(context,returnTypes,parameters);
> }
>
> /** Base update method
> */
> function doObjectUpdate(context,returnTypes,parameters)
> {
>         doc = context.getResponse().getWriter();
>         for (prop in parameters.keys())
>         {
>                 if (prop.indexOf('prop_') == 0)
>                 {
>                         value = parameters.get(prop);
>                         attrib = prop.substring(5);
>                         if (value == null || value==&quot;&quot;)
>                         {
>                                 xml.removeAttribute(attrib);
>                         }
>                         else
>                         {
>                                 xml.setAttribute(attrib,value);
>                         }
>
>                 }
>         }
>
>         context.getResponse().setContentType(&quot;text/html&quot;);
>
> doc.println(&quot;&lt;html&gt;&lt;body&gt;OK&lt;/body&gt;&lt;/html
> &gt;&quot;);
> }
>
> function doObjectAddProp(context,returnTypes,parameters)
> {
>         name = parameters.get('name');
>         value = parameters.get('value');
>         xml.setAttribute(name,value);
>
>         context.getResponse().setContentType(&quot;text/html&quot;);
>         doc = context.getResponse().getWriter();
>
> doc.println(&quot;&lt;html&gt;&lt;body&gt;&quot;+name+&quot;=&quot
> ;+value+&quot;&lt;/body&gt;&lt;/html&gt;&quot;);
> }
>
>
>
>
>
> function debug(s)
> {
>         Packages.java.lang.System.out.println(s);
> }
>
> function getInheritedAttribute(element,name)
> {
>         var value;
>         value=null;
>
>         while ((element != null) &amp;&amp; (element.getNodeType() ==
> 1))
>         {
>                 value = element.getAttribute(name);
>                 if (value != null &amp;&amp; value != &quot;&quot;)
>                         break;
>
>                 element = element.getParentNode();
>         }
>         return value;
> }
>
> function getLayout(element)
> {
>         return getInheritedAttribute(element,'layout');
> }
>
> /**
> * This determines which XSL stylesheet to use and applies the stylesheet
> to the targeted
> * element.
> */
> function get(context,returnTypes,parameters)
> {
>         var doc;
>         var layout;
>
>         debug('in get()');
>         doc = context.getResponse().getWriter();
>
>         // check for object
>         if (xml == null)
>         {
>                 context.getResponse().sendError(404,&quot;Page not
> found.&quot;);
>                 return;
>         }
>
>         // require a trailing slash.
>         var path;
>         path = context.getRequest().getPathInfo();
> <b>     if (path.charAt(path.length-1) != '/')
> </b>    {
>                 app.redirectTo(context,path+&quot;/&quot;);
>                 return;
>         }
>
>         // get the url to the XSL to use for the transform.
>         base = getInheritedAttribute(xml,'resources.server');
>
>         layout = parameters.get('layout');
>         if (layout == null)
>         {
>                 layout = getLayout(xml);
>         }
>
>         if (base != null &amp;&amp; (layout.indexOf(':') &lt;= 1))
>         {
>                 media_root =
> Packages.org.apache.xang.util.ServletUtil.getRealPath(context);
>                 layout = media_root + &quot;/&quot; + base + layout;
>                 layout =
> &quot;file:///&quot;+Packages.org.apache.xang.util.ServletUtil.res
> olveURL(layout);
>         }
>
>         if (layout != null)
>         {
>
> context.getResponse().setContentType(&quot;text/html&quot;);
>                 // do XSL via Xalan
>                 {
>                         processor =
> Packages.org.apache.xalan.xslt.XSLTProcessorFactory.getProcessorUs
> ingLiaisonName(&quot;org.apache.xalan.xpath.xdom.XercesLiaison&quot;);
>
>                         source = new
> Packages.org.apache.xalan.xslt.XSLTInputSource();
>                         source.setNode(xml);
>
>                         stylesheet = new
> Packages.org.apache.xalan.xslt.XSLTInputSource();
>                         stylesheet.setSystemId(layout);
>
>                         output = new
> Packages.org.apache.xalan.xslt.XSLTResultTarget();
>                         output.setCharacterStream(doc);
>
>                         processor.process(source,stylesheet,output);
>                 }
>
>                 doc.flush();
>         }
> }
>
> function getXML(context,returnTypes,parameters)
> {
>         doc = context.getResponse().getWriter();
>         doc.println(&quot;&lt;?xml version='1.0' ?&gt;&quot;);
>         doc.println(&quot;&lt;!-- cool huh? --&gt;&quot;);
>         doc.println(xml.getXML());
> }
>
> function getScript(context,returnTypes,parameters)
> {
>         var doc;
>         var s;
>         var util;
>
>         doc = context.getResponse().getWriter();
>
>         util = new Packages.org.apache.xang.util.TextUtil();
>
>
>         s = &quot;&lt;html&gt;&lt;body&gt;&lt;pre&gt;&quot;;
>         s += util.encodeToHTML(app.loadScript(null));
>         s += &quot;&lt;/pre&gt;&lt;/body&gt;&lt;/html&gt;&quot;;
>         doc.println(s);
>         doc.flush();
> }
>
>
> </pre>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: xang-dev-unsubscribe@xml.apache.org
> For additional commands, e-mail: xang-dev-help@xml.apache.org