On Thu, 19 Apr 2007 07:42:32 +0100
"Dave Pawson" <[EMAIL PROTECTED]> wrote:

> On 18/04/07, Michael B Allen <[EMAIL PROTECTED]> wrote:
> > Can someone recommend how I might transform something like the following:
> >
> > <text:p text:style-name="p_5f_soemthing_else">blah</text:p>
> > <text:p text:style-name="p_5f_prototype">session_start();</text:p>
> > <text:p text:style-name="p_5f_prototype">require_once('foo.php');</text:p>
> > <text:p text:style-name="p_5f_prototype"/>
> > <text:p text:style-name="p_5f_prototype">bool some_function(resource 
> > $px,</text:p>
> > <text:p text:style-name="p_5f_prototype"><text:s text:c="8"/>string 
> > $ssn_id,</text:p>
> > <text:p text:style-name="p_5f_prototype"><text:s text:c="8"/>array 
> > $options=NULL)</text:p>
> > <text:p text:style-name="p_5f_soemthing_else">blah</text:p>
> > <text:p text:style-name="p_5f_prototype">another proto ...</text:p>
> >
> > into the this:
> >
> > <pre>session_start();
> > require_once('foo.php');
> >
> > bool some_function(resource $px,
> >         string $ssn_id,
> >         array $options=NULL)</pre>
> >
> > <pre>another proto ...</pre>
> 
> 
> 
> <xsl:template match="text:p[text:style-name="p_5f_prototype"]>
> <pre>
>  <xsl:value-of select="."/>
> <xsl:value-of select="following-sibling::text:[EMAIL 
> PROTECTED]:style-name="p_5f_prototype"]
> 
> [preceding-sibling::*[1][self:text:[EMAIL 
> PROTECTED]:style-name="p_5f_prototype"]]]
> </pre>
> </
> 
> <xsl:template match="text:p[text:style-name="p_5f_prototype"]
> />

I don't see how that would work. The follow-sibling conditions would
pick up subsequent p_5f_prototype sequences.

Anyway, I have a solution working. It doesn't quite handle space perfectly
but it's a work in progress.

<xsl:template match="text:[EMAIL PROTECTED]:style-name='p_5f_prototype' and 
not(preceding-sibling::[EMAIL PROTECTED]:style-name='p_5f_prototype'])]">
    <xsl:variable name="end" 
select="following-sibling::*[not(@text:style-name='p_5f_prototype')][1]"/>
    <pre>   
        <xsl:apply-templates mode="proto" select=".|following-sibling::*[. 
&lt;&lt; $end]"/>
    </pre><xsl:text>
</xsl:text>
</xsl:template>

<xsl:template mode="proto" match="text:[EMAIL PROTECTED]:c]">
    <xsl:value-of select="substring('                     ', 1, @text:c)"/>
</xsl:template>

<xsl:template mode="proto" match="text()|@*">
    <xsl:value-of select="."/><xsl:text>
</xsl:text>
</xsl:template>

<!-- this is necessary to discard the secondary elements not picked up by the 
primary p_5f_prototype rule -->
<xsl:template match="text:[EMAIL PROTECTED]:style-name='p_5f_prototype' and 
preceding-sibling::[EMAIL PROTECTED]:style-name='p_5f_prototype']]">
</xsl:template>

Mike

-- 
Michael B Allen
PHP Active Directory Kerberos SSO
http://www.ioplex.com/

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to