Re: [xsl] Copying image files from one directory to another - using xslt

Subject: Re: [xsl] Copying image files from one directory to another - using xslt
From: Martin Honnen <Martin.Honnen@xxxxxx>
Date: Tue, 15 Sep 2009 16:14:58 +0200
Amit Panwar wrote:



2). In another transformation I'm reading a html files using unparsed-text() function, now html data can have any number of 'img' tags. I want to use a loop to check all 'img' tags and want to change value of src attribute of each img tag - via string manipulation.

Here is a example java code what i want to achieve in xslt.

String htmlData; // varibale htmlData will have html contents of a files

while(htmlData.indexOf("img") != -1){
Do some processing then replace the value of src attribute then take a substring of html data to remove current img tag.
htmlData = htmlData.substring(htmlData.indexOf("img")+3);
}

Are you using XSLT 2.0? Then you could use David Carlisle's XSLT implementation of a HTML parser
http://www.dcarlisle.demon.co.uk/htmlparse.xsl
and use that the parse the HTML you read in with unparsed-text into nodes you can then process with XSLT templates.


Or with Saxon 9.2 you can use
http://www.saxonica.com/documentation9.2/extensions/functions/parse-html.html
to parse HTML into nodes.


--


	Martin Honnen
	http://msmvps.com/blogs/martin_honnen/

Current Thread