Page 1 of 1

XSL transformation

Posted: Mon Nov 10, 2003 11:53 pm
by agashirazi
Hey guys,

First of all, I think its great we have a FREE forum thats actually out to help others.

Guys, I have an XML file with three tags i.e. <author>. Now I want to reinsert this into another XML file using an XSL query. I use the same value-of command, but it just gets the first author from the XML file, and pastes it thrice. I know why this is happening, but I do not want to go back and rename the author tags in the first XML file to author1, author2 and author3. Is there any other way out of it?

Once again, im really appreciative of this.

Thanks a million
Aga Shirazi

Posted: Tue Nov 11, 2003 10:46 am
by george
Dear Aga,

There are a lot of possible answers and one cannot know what fits best your needs unless you provide more details. Please consider posting a cut down sample that shows your problem.

Sure you do not need to rename the author tags as author1, author2, etc. you can access each of them separately. For instance if you use an XPath expression like //author you can access all the author elements in your input document. If you want to iterate through them you can use

Code: Select all


<xsl:for-each select="//author">...</xsl:for-each>
You can have a template that matches author an if you issue apply-templates that will act on author elements that template will be activated.
If you want to access the first three author elements then //author[1], //author[2] and //author[3] will select them respectivelly.

Best Regards,
George