p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   XSLT (http://p2p.wrox.com/forumdisplay.php?f=86)
-   -   Dynamically cha nging root node!!!!!!! (http://p2p.wrox.com/showthread.php?t=69718)

rakesh July 29th, 2008 08:59 AM

Dynamically cha nging root node!!!!!!!
I have an xml file for which i have prepared an xslt. I will using .net application to dynamically assign xslt to the xml file.

Now i have a requirement. The root node of xml file can sometimes be <Resp_AppDetail> or <Resp_Submit>. Now depending
on this i have to change the match of <xsl:template match="">. Is it possible to switch "match" template
using if else or so, depending on the output xml root node. If possible where should i do this? in .Net application or XSLT?
Any clue on how should i achieve this?


samjudson July 29th, 2008 09:13 AM

Is this what you mean?

<xsl:template match="Resp_AppDetail | Resp_Submit">

/- Sam Judson : Wrox Technical Editor -/

samjudson July 29th, 2008 09:19 AM

Alternatively to match the root of the document, just use <xsl:template match="/">.

/- Sam Judson : Wrox Technical Editor -/

mhkay July 29th, 2008 09:29 AM

Various strategies are possible:

(a) you can define a template rule that matches either of these element names (match="A|B")

(b) you can define two different template rules for the two different element names (it doesn't matter if one of the rules is unused)

(c) you can define two separate stylesheets for the two document types, with the common code that they share included into both using xsl:import.

Option (c) is probably the one that gives you most flexibility in the future.

Michael Kay
Author, XSLT 2.0 and XPath 2.0 Programmer's Reference

rakesh July 29th, 2008 09:31 AM

Taks for these various thoughts.

All times are GMT -4. The time now is 12:58 PM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.