[XSL-LIST Mailing List Archive Home]
[By Thread]
[By Date]
RE: [xsl] apply-templates vs. call-template problem
Subject: RE: [xsl] apply-templates vs. call-template problem From: "Michael Kay" <mike@xxxxxxxxxxxx> Date: Mon, 16 Jun 2008 14:36:29 +0100 |
There is no "select" attribute on xsl:call-template. If this isn't being reported as an error in your stylesheet then you need to raise a bug report on xsltproc - it's a conformance requirement that such errors be reported. The only way to change the context node when calling xsl:call-template is <xsl:for-each select="$top"> <xsl:call-template name="xyz"/. </xsl:for-each> Michael Kay http://www.saxonica.com/ > -----Original Message----- > From: Greg Fausak [mailto:lgfausak@xxxxxxxxx] > Sent: 16 June 2008 14:22 > To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx > Cc: lgfausak@xxxxxxxxx > Subject: [xsl] apply-templates vs. call-template problem > > 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,tabl > eindices,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] apply-templates vs. call-, Greg Fausak | Thread | Re: [xsl] apply-templates vs. call-, David Carlisle |
Re: [xsl] apply-templates vs. call-, Martin Honnen | Date | RE: [xsl] Check the last character , Michael Kay |
Month |