[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]
Subject: RE: [docbook-apps] Request for help with XSL: template for proces singinstruction not getting called
First, I just got it to work, but here's some additional information on what I was doing. Jeff Beal <jeff.beal@ansys.com> wrote on 10/03/2003 08:48:37 AM: > You're right. There shouldn't be any overlap between these two templates. > Which processor are you using? I'm using xsltproc. To give you more information, here are the two templates in my customization layer: <xsl:import href="/usr/share/docbook-xsl/htmlhelp/htmlhelp.xsl"/> <xsl:template match="processing-instruction('dbhh')" mode="hh-alias"> <xsl:variable name="topicname"> <xsl:call-template name="pi-attribute"> <xsl:with-param name="pis" select="."/> <xsl:with-param name="attribute" select="'topicname'"/> </xsl:call-template> </xsl:variable> <xsl:variable name="href"> <xsl:call-template name="href.target.with.base.dir"> <xsl:with-param name="object" select=".."/> </xsl:call-template> </xsl:variable> <xsl:value-of select="$topicname"/> <xsl:text>=</xsl:text> <xsl:value-of select="substring-before(concat($href, '#'), '#')"/>#<xsl:value-of select="$topicname"/> <xsl:text>
</xsl:text> </xsl:template> <xsl:template match="*" mode="hh-alias"> <xsl:if test="@id"> <xsl:value-of select="@id"/> <xsl:text> = </xsl:text> <xsl:call-template name="href.target"/> <xsl:text>
</xsl:text> </xsl:if> <xsl:apply-templates select="*" mode="hh-alias"/><!-- recurse into subelements --> </xsl:template> My customization layer imports the htmlhelp.xsl stylesheet, which in turn includes htmlhelp-common.xsl, where the following templates are defined: <xsl:template name="hh-alias"> <xsl:call-template name="write.text.chunk"> <xsl:with-param name="filename"> <xsl:if test="$manifest.in.base.dir != 0"> <xsl:value-of select="$base.dir"/> </xsl:if> <xsl:value-of select="$htmlhelp.alias.file"/> </xsl:with-param> <xsl:with-param name="method" select="'text'"/> <xsl:with-param name="content"> <xsl:choose> <xsl:when test="$rootid != ''"> <xsl:apply-templates select="key('id',$rootid)" mode="hh-alias"/> </xsl:when> <xsl:otherwise> <xsl:apply-templates select="/" mode="hh-alias"/> </xsl:otherwise> </xsl:choose> </xsl:with-param> <xsl:with-param name="encoding" select="$htmlhelp.encoding"/> </xsl:call-template> </xsl:template> <xsl:template match="processing-instruction('dbhh')" mode="hh-alias"> <xsl:variable name="topicname"> <xsl:call-template name="pi-attribute"> <xsl:with-param name="pis" select="."/> <xsl:with-param name="attribute" select="'topicname'"/> </xsl:call-template> </xsl:variable> <xsl:variable name="href"> <xsl:call-template name="href.target.with.base.dir"> <xsl:with-param name="object" select=".."/> </xsl:call-template> </xsl:variable> <xsl:value-of select="$topicname"/> <xsl:text>=</xsl:text> <!-- Some versions of HH doesn't like fragment identifires, but some does. --> <!-- <xsl:value-of select="substring-before(concat($href, '#'), '#')"/> --> <xsl:value-of select="$href"/> <xsl:text>
</xsl:text> </xsl:template> <xsl:template match="text()" mode="hh-alias"/> Joerg asked: > Is the template >matching on elements called *instead* of the original template matching >on this specific processing instruction? If I don't miss anything it Yes. The rule <xsl:template match="processing-instruction('dbhh')" mode="hh-alias"> gets called only if I don't have <xsl:template match="*" mode="hh-alias"> rule. Jirka asked: >And how does this template looks. It must contain <xsl:apply-templates/> >in order to invoke templates for child nodes including PI nodes. As you see in my <xsl:template match="*" mode="hh-alias">, it does call <xsl:apply-templates select="*" mode="hh-alias"/>. *** At this point, I realized this is the problematic line. The select expression "*" does not catch processing instructions. If I say simply <xsl:apply-templates/>, the processing does not seem to recurse correctly. I only get output from the root node. I don't know why. Perhaps someone can teach me why. When I tried this I was successful: <xsl:apply-templates mode-"hh-alias"/> The following also works: <xsl:apply-templates select="*|processing-instruction()" mode-"hh-alias"/> So the XSL lesson I learned was that "*" does not match processing instructions. But I still don't know why the simple rule <xsl:apply-templates/> does not recurse into child nodes. -Taro
[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]