You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@turbine.apache.org by Eric Emminger <er...@ericemminger.com> on 2003/06/10 19:04:04 UTC

Re: Generating VM from XML file dynamically

 > I need generate VM file from an XML file dynamically and also 
populate some
 > fields in the VM file from different tables, the criteria for query is in
 > XML file.
 > How this can be achived?

Sounds like XSLT. Can you give an example so we can help?

Eric


---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-user-help@jakarta.apache.org


Re: Generating VM from XML file dynamically

Posted by Eric Emminger <er...@ericemminger.com>.
Keshava

I don't know enough about XSL/XSLT to tell you how you can do this. 
Maybe you could transform your XML document using XSL and then 
manipulate that in Velocity using the ideas I gave you earlier.

Eric

Keshava Murthy wrote:
> Eric,
> 
> I also want you to know that the contents of XML file is generated
> dynamically from user interface and xml content is not known.
> 
> I will just brief you about the application-
> 
> The application is for developing a lab note book wherein the users will
> create their own protocols. The protocol is entered in UI. The HTML
> docuement is to be converted to  XML document(template) and later the XML
> document is to be displayed to the user in proper layout using xsl with data
> populated from database tables. All these things has happen dynamically.
> 
> regards,
> Keshava Murthy. S
> 
> 
> ----- Original Message -----
> From: "Keshava Murthy" <ke...@bigtec.org>
> To: "Turbine Users List" <tu...@jakarta.apache.org>
> Sent: Saturday, June 14, 2003 1:00 PM
> Subject: Re: Generating VM from XML file dynamically
> 
> 
> 
>>Eric,
>>Thanks for the code. But how do I transform the XML using xsl. Unless this
>>is done the layout will not be proper.
>>regards,
>>Keshava Murthy. S
>>
>>
>>----- Original Message -----
>>From: "Eric Emminger" <er...@ericemminger.com>
>>To: "Turbine Users List" <tu...@jakarta.apache.org>
>>Sent: Saturday, June 14, 2003 3:42 AM
>>Subject: Re: Generating VM from XML file dynamically
>>
>>
>>
>>>Keshava
>>>
>>>
>>>>I was able to convert XML to VM file using turbine's
>>
>>TurbineXSLTService.
>>
>>>>The Screen class code, xml and xsl file ares in the attached
> 
> docuemnts.
> 
>>>>However I have no idea how I can populate the components when VM file
> 
> is
> 
>>>>displayed. I would like to take the approach you sugeested but I have
>>
>>not
>>
>>>>used DOM4J before, can you send me sample code how to go about.
>>>
>>>I suggest using a pull tool. Create a method that returns a Document
>>>using the following code with DOM4J.
>>>
>>>public Document getDocument() {
>>>// get the actual xml file; this is just an example
>>>File file = new File("protocol.xml");
>>>SAXReader reader = new SAXReader();
>>>Document doc = reader.read(file);
>>>return doc;
>>>}
>>>
>>>Create another method that returns a List of dates from the database.
>>>
>>>public List getDateList(String table, String column, String where) {
>>>// create an SQL statement from table, column, and where
>>>}
>>>
>>>In your VM template, do this.
>>>
>>>#set($doc = $pullTool.getDocument())
>>>#set($date = $doc.selectNodes("/protocol/materials/solution/date"))
>>>#set($table = $date.valueOf("@table"))
>>>## set $column
>>>## set $where
>>><select name="select" size="10" multiple="true" style="width:150px;">
>>>#foreach($option in $pullTool.getDateList($table, $column, $where))
>>>     <option>$option</option>
>>>#end
>>></select>
>>>
>>>
>>>Eric
>>>
>>>
>>>---------------------------------------------------------------------
>>>To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
>>>For additional commands, e-mail: turbine-user-help@jakarta.apache.org
>>>
>>>
>>
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
>>For additional commands, e-mail: turbine-user-help@jakarta.apache.org
>>
>>
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: turbine-user-help@jakarta.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-user-help@jakarta.apache.org


Re: Generating VM from XML file dynamically

Posted by Keshava Murthy <ke...@bigtec.org>.
Eric,

I also want you to know that the contents of XML file is generated
dynamically from user interface and xml content is not known.

I will just brief you about the application-

The application is for developing a lab note book wherein the users will
create their own protocols. The protocol is entered in UI. The HTML
docuement is to be converted to  XML document(template) and later the XML
document is to be displayed to the user in proper layout using xsl with data
populated from database tables. All these things has happen dynamically.

regards,
Keshava Murthy. S


----- Original Message -----
From: "Keshava Murthy" <ke...@bigtec.org>
To: "Turbine Users List" <tu...@jakarta.apache.org>
Sent: Saturday, June 14, 2003 1:00 PM
Subject: Re: Generating VM from XML file dynamically


> Eric,
> Thanks for the code. But how do I transform the XML using xsl. Unless this
> is done the layout will not be proper.
> regards,
> Keshava Murthy. S
>
>
> ----- Original Message -----
> From: "Eric Emminger" <er...@ericemminger.com>
> To: "Turbine Users List" <tu...@jakarta.apache.org>
> Sent: Saturday, June 14, 2003 3:42 AM
> Subject: Re: Generating VM from XML file dynamically
>
>
> > Keshava
> >
> > > I was able to convert XML to VM file using turbine's
> TurbineXSLTService.
> > > The Screen class code, xml and xsl file ares in the attached
docuemnts.
> > > However I have no idea how I can populate the components when VM file
is
> > > displayed. I would like to take the approach you sugeested but I have
> not
> > > used DOM4J before, can you send me sample code how to go about.
> >
> > I suggest using a pull tool. Create a method that returns a Document
> > using the following code with DOM4J.
> >
> > public Document getDocument() {
> > // get the actual xml file; this is just an example
> > File file = new File("protocol.xml");
> > SAXReader reader = new SAXReader();
> > Document doc = reader.read(file);
> > return doc;
> > }
> >
> > Create another method that returns a List of dates from the database.
> >
> > public List getDateList(String table, String column, String where) {
> > // create an SQL statement from table, column, and where
> > }
> >
> > In your VM template, do this.
> >
> > #set($doc = $pullTool.getDocument())
> > #set($date = $doc.selectNodes("/protocol/materials/solution/date"))
> > #set($table = $date.valueOf("@table"))
> > ## set $column
> > ## set $where
> > <select name="select" size="10" multiple="true" style="width:150px;">
> > #foreach($option in $pullTool.getDateList($table, $column, $where))
> >      <option>$option</option>
> > #end
> > </select>
> >
> >
> > Eric
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: turbine-user-help@jakarta.apache.org
> >
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: turbine-user-help@jakarta.apache.org
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-user-help@jakarta.apache.org


Re: Generating VM from XML file dynamically

Posted by Keshava Murthy <ke...@bigtec.org>.
Eric,
Thanks for the code. But how do I transform the XML using xsl. Unless this
is done the layout will not be proper.
regards,
Keshava Murthy. S


----- Original Message -----
From: "Eric Emminger" <er...@ericemminger.com>
To: "Turbine Users List" <tu...@jakarta.apache.org>
Sent: Saturday, June 14, 2003 3:42 AM
Subject: Re: Generating VM from XML file dynamically


> Keshava
>
> > I was able to convert XML to VM file using turbine's
TurbineXSLTService.
> > The Screen class code, xml and xsl file ares in the attached docuemnts.
> > However I have no idea how I can populate the components when VM file is
> > displayed. I would like to take the approach you sugeested but I have
not
> > used DOM4J before, can you send me sample code how to go about.
>
> I suggest using a pull tool. Create a method that returns a Document
> using the following code with DOM4J.
>
> public Document getDocument() {
> // get the actual xml file; this is just an example
> File file = new File("protocol.xml");
> SAXReader reader = new SAXReader();
> Document doc = reader.read(file);
> return doc;
> }
>
> Create another method that returns a List of dates from the database.
>
> public List getDateList(String table, String column, String where) {
> // create an SQL statement from table, column, and where
> }
>
> In your VM template, do this.
>
> #set($doc = $pullTool.getDocument())
> #set($date = $doc.selectNodes("/protocol/materials/solution/date"))
> #set($table = $date.valueOf("@table"))
> ## set $column
> ## set $where
> <select name="select" size="10" multiple="true" style="width:150px;">
> #foreach($option in $pullTool.getDateList($table, $column, $where))
>      <option>$option</option>
> #end
> </select>
>
>
> Eric
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: turbine-user-help@jakarta.apache.org
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-user-help@jakarta.apache.org


Re: Generating VM from XML file dynamically

Posted by Eric Emminger <er...@ericemminger.com>.
Keshava

> I was able to convert XML to VM file using turbine's  TurbineXSLTService.
> The Screen class code, xml and xsl file ares in the attached docuemnts.
> However I have no idea how I can populate the components when VM file is
> displayed. I would like to take the approach you sugeested but I have not
> used DOM4J before, can you send me sample code how to go about.

I suggest using a pull tool. Create a method that returns a Document 
using the following code with DOM4J.

public Document getDocument() {
// get the actual xml file; this is just an example
File file = new File("protocol.xml");
SAXReader reader = new SAXReader();
Document doc = reader.read(file);
return doc;
}

Create another method that returns a List of dates from the database.

public List getDateList(String table, String column, String where) {
// create an SQL statement from table, column, and where
}

In your VM template, do this.

#set($doc = $pullTool.getDocument())
#set($date = $doc.selectNodes("/protocol/materials/solution/date"))
#set($table = $date.valueOf("@table"))
## set $column
## set $where
<select name="select" size="10" multiple="true" style="width:150px;">
#foreach($option in $pullTool.getDateList($table, $column, $where))
     <option>$option</option>
#end
</select>


Eric


---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-user-help@jakarta.apache.org


Re: Generating VM from XML file dynamically

Posted by Keshava Murthy <ke...@bigtec.org>.
Hi Eric,

I was able to convert XML to VM file using turbine's  TurbineXSLTService.
The Screen class code, xml and xsl file ares in the attached docuemnts.
However I have no idea how I can populate the components when VM file is
displayed. I would like to take the approach you sugeested but I have not
used DOM4J before, can you send me sample code how to go about.

regards
Keshava Murthy. S



----- Original Message -----
From: "Eric Emminger" <er...@ericemminger.com>
To: "Turbine Users List" <tu...@jakarta.apache.org>
Sent: Thursday, June 12, 2003 6:38 PM
Subject: Re: Generating VM from XML file dynamically


> Keshava
>
> Keshava Murthy wrote:
> > I am giving below a part of xml file -
> >
> > <solution>
> > <stat>Alkaline Lysis Solution</stat>
> > <date type="cb" name="MI01" table="mas_solutions" col="soln_prepdt"
> > where="soln_name='Alkaline Lysis Solution'"> </date>
> > </solution>
> >
> > When this is converted to VM file, the component should be a dropdown
> > menu(type="cb" --> cb indicates it is Combo box) and name of the
component
> > should be MI01 and it should have data populated from "soln_prepdt"
column
> > from "mas_solutions" table where  "soln_name" ='Alkaline Lysis
Solution'.
>
> Interesting. Here's how I did something similar.
>
> Using DOM4J, load your XML file as a Document and put it in the Velocity
> context. In your VM (Velocity template), step through the Document,
> creating the HTML you need.
>
> Eric
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: turbine-user-help@jakarta.apache.org
>
>

Re: Generating VM from XML file dynamically

Posted by Eric Emminger <er...@ericemminger.com>.
Keshava

Keshava Murthy wrote:
> I am giving below a part of xml file -
> 
> <solution>
> <stat>Alkaline Lysis Solution</stat>
> <date type="cb" name="MI01" table="mas_solutions" col="soln_prepdt"
> where="soln_name='Alkaline Lysis Solution'"> </date>
> </solution>
> 
> When this is converted to VM file, the component should be a dropdown
> menu(type="cb" --> cb indicates it is Combo box) and name of the component
> should be MI01 and it should have data populated from "soln_prepdt" column
> from "mas_solutions" table where  "soln_name" ='Alkaline Lysis Solution'.

Interesting. Here's how I did something similar.

Using DOM4J, load your XML file as a Document and put it in the Velocity 
context. In your VM (Velocity template), step through the Document, 
creating the HTML you need.

Eric


---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-user-help@jakarta.apache.org


Re: Generating VM from XML file dynamically

Posted by Keshava Murthy <ke...@bigtec.org>.
I am giving below a part of xml file -

<solution>
<stat>Alkaline Lysis Solution</stat>
<date type="cb" name="MI01" table="mas_solutions" col="soln_prepdt"
where="soln_name='Alkaline Lysis Solution'"> </date>
</solution>

When this is converted to VM file, the component should be a dropdown
menu(type="cb" --> cb indicates it is Combo box) and name of the component
should be MI01 and it should have data populated from "soln_prepdt" column
from "mas_solutions" table where  "soln_name" ='Alkaline Lysis Solution'.

Keshava Murthy. S

----- Original Message -----
From: "Eric Emminger" <er...@ericemminger.com>
To: "Turbine Users List" <tu...@jakarta.apache.org>
Sent: Tuesday, June 10, 2003 10:34 PM
Subject: Re: Generating VM from XML file dynamically


> > I need generate VM file from an XML file dynamically and also
> populate some
>  > fields in the VM file from different tables, the criteria for query is
in
>  > XML file.
>  > How this can be achived?
>
> Sounds like XSLT. Can you give an example so we can help?
>
> Eric
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: turbine-user-help@jakarta.apache.org
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-user-help@jakarta.apache.org