[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: creating XML in a servlet

Subject: RE: creating XML in a servlet
From: "Najmi, Jamal" <Jamal.Najmi@xxxxxxxxxxx>
Date: Mon, 8 Apr 2002 02:54:51 -0400
servlet create xml
Hi Jeni, 

Thanks a lot for the much needed detailed response!!   I will definitely
look into Cocoon.  If I may ask one more question - as I am new to XSL so
this is a very basic question: in order for me to accomplish what I want to
accomplish,  servlet needs to be able to interact with the XSL and get the
output of XSL back and build XML in memory. Is this possible?  I mean is
there API defined through which Java can interact with the XSL back and
forth.

Thanks!!

Jamal 

-----Original Message-----
From: Jeni Tennison [mailto:jeni@xxxxxxxxxxxxxxxx]
Sent: Saturday, April 06, 2002 3:23 PM
To: Najmi, Jamal
Cc: 'xsl-list@xxxxxxxxxxxxxxxxxxxxxx'
Subject: Re:  creating XML in a servlet


Hi Jamal,

> I want to know if it is possible to create chunks of XML based on
> certain parameters that a servlet receives from a form submitted by
> a web client.

In principle, yes. This is possible in Cocoon, for example, provided
that you configure it correctly.

> For example if form parameter name = 'title', and value of this
> parameter is 'Football', then ask XSL to create the following chunk
> of XML:
>
> <title>Football</title>

In XSLT, the names of the parameters that a stylesheet uses must be
hardcoded into the stylesheet. So you could declare the $title
parameter:

<xsl:param name="title" />

and then pass in the value 'Football' for that title parameter, and
do:

  <title>
    <xsl:value-of select="$title" />
  </title>

But you can't vary the name of the parameter.

On the other hand, you could have a general parameter called
'parameter', for example:

<xsl:param name="parameter" />

and then use some delimiter in the value of that parameter to create
an element with a value. You can then pull the parameter value into a
'name' and 'value' using substring-before() and substring-after()
functions. Then create the element with a particular name using an
attribute value template in the name attribute of the xsl:element
instruction.

So for example if the $parameter parameter was set to 'title:Football'
then you could create the title element with:

  <xsl:element name="{substring-before($parameter, ':')}">
    <xsl:value-of select="substring-after($parameter, ':')" />
  </xsl:element>

Or have separate parameters for the name and value of the element.
  
Cheers,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.