You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@lenya.apache.org by Sean Fulton <fu...@cmu.edu> on 2005/05/11 17:14:31 UTC
Modifying XHTML document content
I'd like to automatically add an anchor to each h2 tag on a page. Has
anyone tried something like this? Where is the best place to do that?
Doing it in the editor won't work because different people may use
different editors.
Thanks,
Sean
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@lenya.apache.org
For additional commands, e-mail: user-help@lenya.apache.org
Re: Modifying XHTML document content
Posted by Doug Chestnut <dh...@virginia.edu>.
Sean Fulton wrote:
> Can you tell me how this works:
> <xsl:if test="$rendertype = 'edit'">
> <a name="anchor"> </a>
> </xsl:if>
>
> Is this what suppresses the output of the anchors in the editing view?
Actually I made a typo, it should be $rendertype != 'edit' (page is not
being edited).
This template just copys the h2 element (and attributes if any) to the
result document, if the doc is not being edited, an anchor is written to
the result doc, and then any children nodes are passed to other
templates (most likely matched by the identity template).
<h2>hello world</h2>
should become
<h2><a name="anchor"> </a> hello world</h2>
when the document is not being edited.
--Doug
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@lenya.apache.org
For additional commands, e-mail: user-help@lenya.apache.org
Re: Modifying XHTML document content
Posted by Sean Fulton <fu...@cmu.edu>.
Thanks, Doug. That got me in the right track. I'm using:
<xsl:template match="xhtml:h2">
<xsl:copy>
<xsl:apply-templates select="@*"/>
<xsl:if test="$rendertype = 'edit'">
<a name="anchor"> </a>
</xsl:if>
<a name="{.}">
<xsl:apply-templates select="node()"/></a>
</xsl:copy>
</xsl:template>
Can you tell me how this works:
<xsl:if test="$rendertype = 'edit'">
<a name="anchor"> </a>
</xsl:if>
Is this what suppresses the output of the anchors in the editing view?
Sean
On 2005-05-11 11:39:51 -0400, Doug Chestnut <dh...@virginia.edu> said:
> Couldn't you just try something like this in xhtml2xhtml.xsl (or other
> doctype xsl):
>
> <xsl:template match="xhtml:h2">
> <xsl:copy>
> <xsl:apply-templates select="@*"/>
> <xsl:if test="$rendertype = 'edit'">
> <a name="anchor"> </a>
> </xsl:if>
> <xsl:apply-templates select="node()"/>
> </xsl:copy>
> </xsl:template>
>
> You wouldn't want the anchor to show up in the editor, since you
> wouldn't want the anchor to be saved as part of your doc content.
>
> --Doug
>
> Sean Fulton wrote:
>>
>> I'd like to automatically add an anchor to each h2 tag on a page. Has
>> anyone tried something like this? Where is the best place to do that?
>> Doing it in the editor won't work because different people may use
>> different editors.
>>
>> Thanks,
>>
>> Sean
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@lenya.apache.org
>> For additional commands, e-mail: user-help@lenya.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@lenya.apache.org
For additional commands, e-mail: user-help@lenya.apache.org
Re: Modifying XHTML document content
Posted by Doug Chestnut <dh...@virginia.edu>.
Opps, I meant
test="$rendertype != 'edit'"
so that in an editor, the anchor would show up.
--Doug
Doug Chestnut wrote:
> Couldn't you just try something like this in xhtml2xhtml.xsl (or other
> doctype xsl):
>
> <xsl:template match="xhtml:h2">
> <xsl:copy>
> <xsl:apply-templates select="@*"/>
> <xsl:if test="$rendertype = 'edit'">
> <a name="anchor"> </a>
> </xsl:if>
> <xsl:apply-templates select="node()"/>
> </xsl:copy>
> </xsl:template>
>
> You wouldn't want the anchor to show up in the editor, since you
> wouldn't want the anchor to be saved as part of your doc content.
>
> --Doug
>
> Sean Fulton wrote:
>
>>
>> I'd like to automatically add an anchor to each h2 tag on a page. Has
>> anyone tried something like this? Where is the best place to do that?
>> Doing it in the editor won't work because different people may use
>> different editors.
>>
>> Thanks,
>>
>> Sean
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@lenya.apache.org
>> For additional commands, e-mail: user-help@lenya.apache.org
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@lenya.apache.org
> For additional commands, e-mail: user-help@lenya.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@lenya.apache.org
For additional commands, e-mail: user-help@lenya.apache.org
Re: Modifying XHTML document content
Posted by Doug Chestnut <dh...@virginia.edu>.
Couldn't you just try something like this in xhtml2xhtml.xsl (or other
doctype xsl):
<xsl:template match="xhtml:h2">
<xsl:copy>
<xsl:apply-templates select="@*"/>
<xsl:if test="$rendertype = 'edit'">
<a name="anchor"> </a>
</xsl:if>
<xsl:apply-templates select="node()"/>
</xsl:copy>
</xsl:template>
You wouldn't want the anchor to show up in the editor, since you
wouldn't want the anchor to be saved as part of your doc content.
--Doug
Sean Fulton wrote:
>
> I'd like to automatically add an anchor to each h2 tag on a page. Has
> anyone tried something like this? Where is the best place to do that?
> Doing it in the editor won't work because different people may use
> different editors.
>
> Thanks,
>
> Sean
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@lenya.apache.org
> For additional commands, e-mail: user-help@lenya.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@lenya.apache.org
For additional commands, e-mail: user-help@lenya.apache.org