Subject: [xsl] apply-templates vs. call-template problem From: "Greg Fausak" <lgfausak@xxxxxxxxx> Date: Mon, 16 Jun 2008 08:22:24 -0500 |
Hi, I'm using xsltproc on freebsd. I've encountered a problem that I think is because I don't understand xsl/xml namespaces? Anyway, I got my xsl stylesheet to work below using the template: <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:str="http://exslt.org/strings" xmlns:set="http://exslt.org/sets" xmlns:regexp="http://exslt.org/regular-expressions" xmlns:exslt="http://exslt.org/common" xsl:extension-element-prefixes="str set regexp exslt" > <xsl:output method="text" indent="no"/> <xsl:template match="/schema"> <xsl:call-template name="create-groups" select="."/> <xsl:call-template name="create-partitions" select="."/> <xsl:apply-templates select="tables/table"/> <xsl:call-template name="table-permissions" select="."/> <xsl:call-template name="table-indices" select="."/> <xsl:call-template name="oid-indices" select="$top/schema"/> </xsl:template> I then decided it would be nice to just call each template if a command line flag was specified, but, I can't get it to work for the call-template variety. The apply-templates seems to work if I create an anchor $top variable to 'reselect'.... <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:str="http://exslt.org/strings" xmlns:set="http://exslt.org/sets" xmlns:regexp="http://exslt.org/regular-expressions" xmlns:exslt="http://exslt.org/common" xsl:extension-element-prefixes="str set regexp exslt" > <xsl:param name="actions" select="string('groups,partitions,tables,tablepermissions,tableindices,oidindices')"/> <xsl:output method="text" indent="no"/> <xsl:template match="/schema"> <xsl:variable name="top" select="."/> <xsl:for-each select="str:tokenize($actions, ',')"> <xsl:choose> <xsl:when test=". = 'groups'"> <xsl:text>got groups
</xsl:text> <xsl:call-template name="create-groups" select="."/> </xsl:when> <xsl:when test=". = 'partitions'"> <xsl:text>got partitions
</xsl:text> <xsl:call-template name="create-partitions" select="$top"/> </xsl:when> <xsl:when test=". = 'tables'"> <xsl:text>got tables
</xsl:text> <xsl:apply-templates select="$top/tables/table" mode='tables'/> </xsl:when> <xsl:when test=". = 'tablepermissions'"> <xsl:text>got tablepermissions
</xsl:text> <xsl:call-template name="table-permissions" select="."/> </xsl:when> <xsl:when test=". = 'tableindices'"> <xsl:text>got tableindices
</xsl:text> <xsl:call-template name="table-indices" select="."/> </xsl:when> <xsl:when test=". = 'oidindices'"> <xsl:text>got oidindices
</xsl:text> <xsl:apply-templates select="$top/tables/table" mode='oid-indices'/> <!-- <xsl:call-template name="oid-indices" select="$top/schema"/> --> </xsl:when> <xsl:otherwise> <xsl:message terminate="yes"> UNKNOWN command line argument: <xsl:value-of select="."/> </xsl:message> </xsl:otherwise> </xsl:choose> </xsl:for-each> </xsl:template> In this example just the 'apply-templates' calls work. The 'call-template' fires, but I can't seem to 'select' the /schema tree. In both cases my xml data looks like: <schema name="ad_schema" database="ad_voip"> <tables> <table name="at_address" perm="superuser"> <comments> Address This is an address record. It is normally included in other record's views. </comments> <fields> <field is_nullable="1" data_type="text" name="ac_b" > <comments> Brand ID This address belongs to this brand. </comments> </field> ... Thank you, ---greg -- Greg Fausak greg@xxxxxxxxxxxx
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Difficulty with document(, Adam Nielsen | Thread | Re: [xsl] apply-templates vs. call-, Martin Honnen |
RE: [xsl] Need to Split/Un-Nest ele, mandar.jagtap | Date | [xsl] Check the last character (XSL, Pankaj Chaturvedi |
Month |