[XSL-LIST Mailing List Archive Home]
[By Thread]
[By Date]
[xsl] Get nodes with document() and applying templates to them
Subject: [xsl] Get nodes with document() and applying templates to them From: António Mota <amsmota@xxxxxxxxx> Date: Mon, 14 Feb 2005 14:03:28 +0000 |
Hi again: I'm trying to do something like this: Given <Menu> <Menu_K>X00123</Menu_K> <MenuData/> <MenuTipo>TXT</MenuTipo> <MenuTitulo>Ambitos</MenuTitulo> <Menu> <Menu_K>X00124</Menu_K> <MenuData>X00125</MenuData> <MenuTipo>REP</MenuTipo> <MenuTitulo>(...)</MenuTitulo> </Menu> </Menu> and another XML similar (actually it can be the same) <Menu> <Menu_K>X00125</Menu_K> <MenuData/> <MenuTipo>TXT</MenuTipo> <MenuTitulo>Sub-Ambitos</MenuTitulo> <Menu> <Menu_K>X00126</Menu_K> <MenuData/> <MenuTipo>TXT</MenuTipo> <MenuTitulo>Sub-Sub-Ambitos</MenuTitulo> </Menu> </Menu> i want to apply a identity transform that simply replaces the REP menus with the menu whose K is defined on MenuData, so in the example i'll get <Menu> <Menu_K>X00123</Menu_K> <MenuData/> <MenuTipo>TXT</MenuTipo> <MenuTitulo>Ambitos</MenuTitulo> <Menu> <Menu_K>X00125</Menu_K> <MenuData/> <MenuTipo>TXT</MenuTipo> <MenuTitulo>Sub-Ambitos</MenuTitulo> <Menu> <Menu_K>X00126</Menu_K> <MenuData/> <MenuTipo>TXT</MenuTipo> <MenuTitulo>Sub-Sub-Ambitos</MenuTitulo> </Menu> </Menu> </Menu> I've done this <xsl:template match="Menu"> <xsl:choose> <xsl:when test="MenuTipo='REP'"> <xsl:apply-templates select="document('TreeMenu.xml')//Menu[Menu_K=current()/MenuData]/Menu" /> </xsl:when> <xsl:otherwise> <xsl:copy> <xsl:apply-templates select="*"/> </xsl:copy> </xsl:otherwise> </xsl:choose> </xsl:template> wich is working OK, *unless* in the second XML i have also REP menus. In that case the REP menus on the second tree are just ignored, nor are copyed nor REPlaced. What i was hoping to get is the replaced menus, everywere. That is why i'm using apply-templates instead of copy-of, tath copys the entire second tree but withou replacing the REP's. What am i doing wrong in here? Thanks.
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
AW: [xsl] Closing and reopening hie, Huditsch Roman | Thread | Re: [xsl] Get nodes with document(), David Carlisle |
AW: [xsl] Closing and reopening hie, Huditsch Roman | Date | Re: [xsl] Closing and reopening hie, David Carlisle |
Month |
Keywords