velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mathieu Peltier <Mathieu.Pelt...@inrialpes.fr>
Subject Re: [Anakia newbie question] how to replace all custom tag occurrence?
Date Tue, 02 Oct 2001 06:41:32 GMT
>> On Fri, 28 Sep 2001 18:16:21 +0100, robert burrell donkin <robertdonkin@mac.com>
said:
  
 > i'd say that a better approach for this kind of problem is to use some kind
 > of programmatic tool to do this modification before you process it in the
 > template.
 
Ok it works fine with an XSLT stylesheet. Thank you!
 
>> On Thu, 27 Sep 2001 10:37:48 -0700, Jon Stevens <jon@latchkey.com> said:
 
 > Next, post a summary of what you have tried and how it has failed.

See the following for example, but anyway, I think I will use a XSLT stylesheet. 

.vsl file:
 ----------------------------
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
 
#macro (document)
  #foreach ( $item in $treeWalk.allElements($root) )
    ## $root.selectNodes("//*") doesn't  work?
    #if ( $item.getName().equals("emph") )
      tag emph!! : $item.getText()
      #set ($item = $item.setName("font"))
      #set ($item = $item.setAttribute("class", "emph") )
    #end
  #end
   $xmlout.outputString($root)
#end
 
<html>
<head><title>Test</title></head>
<body>
#document()
</body>
</html

xml file test:
----------------------------
<?xml version="1.0" encoding="ISO-8859-1" standalone="no"?>
<document>
<body><p>This is only a <emph>test</emph>. test should be emphasis.</p></body>
</document>

Result:
---------------------------- 
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Test</title>
</head>
 
<body>
  tag emph!! : test
   <document>
<body><p>This is only a <emph>test</emph>. test should be emphasis.</p></body>
</document>
</body>
</html>
----------------------------

-- 
Mathieu Peltier

Mime
View raw message