You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by Cesare Rocchi <ro...@itc.it> on 2003/07/12 13:58:06 UTC

Transforming an xml file into a velocity template via xslt

Hiyall,

this is my first posting to the list. I skimmed the archive but didn't
find a solution to my problem. I'm trying to transform an xml file into
a velocity template file containing velocity statements. What I basically
want to do is to match some tag and its content/attributes and transform
it into a vel statement like:

<if>content</if> = #if(content)

I thought it could be feasible by means of XSLT. Did anyone try a similar
approach to a similar problem? any pointer to previous works?
I'm experimenting and a problem I am facing is that I want some part of
xml not to be modified, but that seems impossible with XSLT; anything
which is a tag is processed. Anyway I continue my experiments...

Thanks in advance,

-c.



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


Re: Transforming an xml file into a velocity template via xslt

Posted by Serge Knystautas <se...@lokitech.com>.
Christoph.Reck@dlr.de wrote:
> If your input is real XML, then use either the DVSL or Anakia to
> transform any XML to anything else. I have a command-line tool
> derived from Anakia (without ANT) to do such type of
> transformations (see attachment).

I was using XSLT for half a dozen XML->HTML transformations, and 
recently converted these to DVSL since I was using Velocity elsewhere, 
and wanted to say DVSL works really great!  Very simple, but similar 
constructs to XSLT with all the extensibility of Velocity.  I'd 
recommend checking it out if you like Velocity.

-- 
Serge Knystautas
President
Lokitech >> software . strategy . design >> http://www.lokitech.com
p. 301.656.5501
e. sergek@lokitech.com


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


Re: Transforming an xml file into a velocity template via xslt

Posted by Ch...@dlr.de.
If your input is real XML, then use either the DVSL or Anakia to
transform any XML to anything else. I have a command-line tool
derived from Anakia (without ANT) to do such type of
transformations (see attachment).

Remember in the vsl template to use a
	#set( $H = '#' )
and then use
	${H}if(...)...${H}end
to emit the hash symbol into the generated template -
since a #if(...)...#end in the *.vsl-template would confuse
the parser. You could even define all VTL directives and use
them directly, e.g.
	#set( $if = '#if' )
	#set( $else = '#else' )
	#set( $end = '#end' )
	#set( $foreach = '#foreach' )
etc.

Hope this helps.

Cheers,
Christoph


Cesare Rocchi wrote:
> Hiyall,
> 
> this is my first posting to the list. I skimmed the archive but didn't
> find a solution to my problem. I'm trying to transform an xml file into
> a velocity template file containing velocity statements. What I basically
> want to do is to match some tag and its content/attributes and transform
> it into a vel statement like:
> 
> <if>content</if> = #if(content)
> 
> I thought it could be feasible by means of XSLT. Did anyone try a similar
> approach to a similar problem? any pointer to previous works?
> I'm experimenting and a problem I am facing is that I want some part of
> xml not to be modified, but that seems impossible with XSLT; anything
> which is a tag is processed. Anyway I continue my experiments...
> 
> Thanks in advance,
> 
> -c.
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: velocity-user-help@jakarta.apache.org
> 
> 

-- 
:) Christoph Reck

RE: Transforming an xml file into a velocity template via xslt

Posted by Bill Chmura <Bi...@Explosivo.com>.
I am not quite following what you are trying to do... Are you trying to
render the XML data or just the structure into velocity?  I am not sure
I can be a big help, but I can try.

None-the-less, if this list is not any help, I have always found
http://www.mulberrytech.com/xsl/xsl-list
To be really helpful with XSL issues.  

Bill

  > -----Original Message-----
  > From: Cesare Rocchi [mailto:rocchi@itc.it] 
  > Sent: Saturday, July 12, 2003 7:58 AM
  > To: velocity-user@jakarta.apache.org
  > Subject: Transforming an xml file into a velocity template via xslt
  > 
  > 
  > Hiyall,
  > 
  > this is my first posting to the list. I skimmed the archive 
  > but didn't find a solution to my problem. I'm trying to 
  > transform an xml file into a velocity template file 
  > containing velocity statements. What I basically want to do 
  > is to match some tag and its content/attributes and 
  > transform it into a vel statement like:
  > 
  > <if>content</if> = #if(content)
  > 
  > I thought it could be feasible by means of XSLT. Did anyone 
  > try a similar approach to a similar problem? any pointer to 
  > previous works? I'm experimenting and a problem I am facing 
  > is that I want some part of xml not to be modified, but 
  > that seems impossible with XSLT; anything which is a tag is 
  > processed. Anyway I continue my experiments...
  > 
  > Thanks in advance,
  > 
  > -c.
  > 
  > 
  > 
  > ------------------------------------------------------------
  > ---------
  > To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
  > For additional commands, e-mail: 
  > velocity-user-help@jakarta.apache.org
  > 


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


RE: Transforming an xml file into a velocity template via xslt

Posted by "A. Kevin Baynes" <kb...@seagullsw.com>.
It sounds to me like you are looking to transform XML in some way other than
using XSLT...

If you want to do your transformation in Java, you should look at JDOM or
DOM4J (I use JDOM - www.jdom.org). You can programmatically transform the
XML document using simple Java syntax. I find performing XML transformations
is easier in Java as opposed to XSLT. I tend to think of XSLT as a scripting
language with an XML syntax.

You can also use JDOM and XSLT together :
http://www-106.ibm.com/developerworks/java/library/x-tipjdom.html

~akb

| -----Original Message-----
| From: Cesare Rocchi [mailto:rocchi@itc.it]
| Sent: Saturday, July 12, 2003 7:58 AM
| To: velocity-user@jakarta.apache.org
| Subject: Transforming an xml file into a velocity template via xslt
|
|
| Hiyall,
|
| this is my first posting to the list. I skimmed the archive but didn't
| find a solution to my problem. I'm trying to transform an xml file into
| a velocity template file containing velocity statements. What I basically
| want to do is to match some tag and its content/attributes and transform
| it into a vel statement like:
|
| <if>content</if> = #if(content)
|
| I thought it could be feasible by means of XSLT. Did anyone try a similar
| approach to a similar problem? any pointer to previous works?
| I'm experimenting and a problem I am facing is that I want some part of
| xml not to be modified, but that seems impossible with XSLT; anything
| which is a tag is processed. Anyway I continue my experiments...
|
| Thanks in advance,
|
| -c.
|
|
|
| ---------------------------------------------------------------------
| To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
| For additional commands, e-mail: velocity-user-help@jakarta.apache.org


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