RE: [xsl] Revision Marking in HTML

Subject: RE: [xsl] Revision Marking in HTML
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Tue, 26 Apr 2005 13:34:06 +0100
Without trying to do detailed work on it, it feels to me as if a solution
such as the following might work:

<xsl:template match="text()">
  <xsl:choose>
    <xsl:when
test="name(preceding::processing-instruction()[1])='xm-insertion_mark_start'
">
      <span class="revcontrol">
        <xsl:value-of select="."/>
      </span>
    </xsl:when>
    <xsl:otherwise>
       <xsl:value-of select="."/>
    </xsl:otherwise>
  </xsl:choose>
</xsl:template> 

> -----Original Message-----
> From: Nadia.Swaby@xxxxxx [mailto:Nadia.Swaby@xxxxxx] 
> Sent: 26 April 2005 13:25
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject: [xsl] Revision Marking in HTML
> 
> Hi All,
> 
> I have been given the task of reworking some XSL stylesheets 
> at work, used
> to convert XML to HTML.  We use XMetal to create our XML 
> documents, and use
> the revision tracking in XMetal to track any changes made to 
> documents.
> XMetal uses processing instructions to mark insertions and 
> deletions.  Here
> are to examples:
> 
> 1) Inline insertion:
> 
> <?xm-insertion_mark_start author="A. Jekyll"
> time="20041103T123406-0500"?>Document revised 
> to:<?xm-insertion_mark_end ?>
> 
> 2) Block insertion:
> 
> <?xm-insertion_mark_start author="A. Jekyll" 
> time="20041103T123413-0500"?>
> <list type="itemized" id="ID6BE23E2rad7702F" export.control="no"
> qmsp.additional.requirements="no">
>       <list.item id="ID6BE23E2rad04ADD" export.control="no"
> qmsp.additional.requirements="no">
>             <para export.control="no"
> qmsp.additional.requirements="no">Change custodian</para>
>       </list.item>
> </list>
> <?xm-insertion_mark_end ?>
> 
> The solution that we are currently using to highlight in 
> inserted data in
> HTML is as follows:
> 
> <xsl:template 
> match="processing-instruction('xm-insertion_mark_start')">
>             <xsl:choose>
>                   <xsl:when test="following-sibling::text()">
>                         <xsl:text 
> disable-output-escaping="yes">&lt;span
> class="revcontrol"></xsl:text>
>                   </xsl:when>
>                   <xsl:otherwise>
>                         <xsl:text 
> disable-output-escaping="yes">&lt;div
> class="revcontrol"></xsl:text>
>                   </xsl:otherwise>
>             </xsl:choose>
>       </xsl:template>
>       <xsl:template
> match="processing-instruction('xm-insertion_mark_end')">
>             <xsl:choose>
>                   <xsl:when test="preceding-sibling::text()">
>                         <xsl:text
> disable-output-escaping="yes">&lt;/span&gt;</xsl:text>
>                   </xsl:when>
>                   <xsl:otherwise>
>                         <xsl:text
> disable-output-escaping="yes">&lt;/div&gt;</xsl:text>
>                   </xsl:otherwise>
>             </xsl:choose>
>       </xsl:template>
> 
> I am looking for a way to mark these revisions in XML that 
> does not require
> the use of d-o-e.  I was thinking of doing something like this:
> 
> <xsl:template 
> match="processing-instruction('xm-insertion_mark_start')">
>             <xsl:choose>
>                   <xsl:when test="following-sibling::text()">
>                         <span class="revcontrol"><xsl:apply-templates
> select="following-sibling::*"/></span>
>                   </xsl:when>
>                   <xsl:otherwise>
>                         <div class="revcontrol"><xsl:apply-templates
> select="following-sibling::*"/></div>
>                   </xsl:otherwise>
>             </xsl:choose>
>       </xsl:template>
> 
> But that results in the data being output twice.
> 
> Does any one have any ideas that could make this work, or is 
> my best bet
> sticking to d-o-e.
> 
> TIA
> 
> Nadia

Current Thread