Thanks for the great tutorial, but I'm still needing just one 
step that gets me from HTML into XML docs.

>>>>> "L" == Leon Messerschmidt <[EMAIL PROTECTED]> writes:

    L> Hi Gary, The XSLTService takes XML input and transforms it with
    L> an XSL stylesheet ... assumes that your Velocity
    L> Layout/Screen/Navigations are XML templates instead of HTML

I had suspected this much from the xdocs, but where I get confused is
when the XSLT is listed as a Service; in fact, I realized at that point
that while I understand what a Service _is_, I haven't the faintest
clue how to actually invoke one.

If I follow the xdocs correctly, to use a service, you have only one
instance and that instance would use a getInstance method to fetch it,
only there is no getInstance in the Layout.

    L> you need to tell a screen which layout to use.  You can use
    L> setLayout to make it use the VelocityXslLayout 

I'm not complaining because I am guilty of this myself, but what is
extremely foggy in the xdocs and the api-docs is the use of String
as a parameter with no direction on what value that string must have.
It's a problem with using javadoc templates (that's _my_ excuse).

Here's what I tried ... and it doesn't work:

    1) I created my own DefaultLayout and listed it in Tr.props as the
       default.  It lives in my webapp's app.modules.layout package.

       services.VelocityService.default.layout = DefaultLayout
       services.VelocityService.default.layout.template = /DefaultLayout.vm

       so far, so good, Velocity uses this layout.

    2) in DefaultLayout.java, I check for the XML request; this is
       easy since the legacy apps will ask for "?xml=<url>", so I have a
       test for that value and attempt to shunt the request based on the
       getParameters result:
       
        String xml = data.getParameters().getString("xml");

        if (xml!=null) { // 

            // XmlTemplate.vm contains the RSS-like xml code and uses
            // the context to populate the template.
            // Is this built by XmlTemplate.java?

            data.setScreenTemplate("XmlTemplate.vm");

        Here is where it gets fuzzy.  None of the following appear to have
        any effect:

            data.setLayout("VelocityXslLayout"); // class name? FQCN?

            data.setLayoutTemplate("RawLayout.vm"); 
            // template with only the $screen_placeholder
            // and no associated java class

        Q: why do the examples prefix template filenames with a slash?

            data.setLayoutTemplate("XmlLayout.vm"); 
            // template with a corresponding XmlLayout.java that is
            // a sub-class of VelocityXslLayout.vm
            // also tried "/XmlLayout.vm"

        Velocity detects the xml parameter, but renders the page using
        no layout at all, with no error messages.  The generated page
        consists of the DOCTYPE header, and empty HTML, HEAD, TITLE
        and BODY tags.

    L> p.s. Remember to turn on XSLT caching in your TR.properties for
    L> production, otherwise you're site is going to be SLLOOOOWWWWWW.

Maybe VelocityXslLayout is not my best choice: My intention is only to
get a raw XML page with no HTML headers; I need to dump the generated
pages back to the caller with nothing more than ContentType and date
headers (the caller processes the XML, not the server).

I selected the XSLT version because it will dump the raw XML data if
no stylesheet can be found (and in the future, I may want to have some
stylesheet processing).  Is there a better way to do this?

I'd do this with XML-RPC except we have firewall issues and port 80
HTTP is the only universal channel. (my XML-RPC questions will come
later) 

I also thought of calling the template engine directly, giving it the
context, the template and the output stream, but simply treating XML
as just another template seemed most flexible for future surprise
requirements.

-- 
Gary Lawrence Murphy <[EMAIL PROTECTED]> TeleDynamics Communications Inc
Business Innovations Through Open Source Systems: http://www.teledyn.com
"Computers are useless.  They can only give you answers."(Pablo Picasso)


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to