[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Stripping or converting HTML tags

Subject: Re: Stripping or converting HTML tags
From: Aaron Johnson <Aaron2.Johnson@xxxxxxxxx>
Date: Tue, 19 Oct 2004 16:46:41 +0100
php match html tags
The idea is that any HTML documents are first passed through a process to
convert them to clean XML files which then have XSL and CSS applied to them
so that they are XHTML compliant and coloured / formatted in a uniform way.

I am trying to work out a way that strips out tables for a "text" only
version of the page.

I have "inherited" this project from someone else and am having real trouble
with it!!

<?xml version="1.0" encoding="ISO-8859-1"?>

<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:xhtml="http://www.w3.org/1999/xhtml"
    xmlns="http://www.w3.org/1999/xhtml"
    exclude-result-prefixes="xhtml">

<xsl:output method="html"/>

<xsl:include href="baseTemplate.xsl" />
    
<!--Aaron test stuff for css -->

<xsl:variable name="ueCssFile"
select="'includes/css/aaron_test.css'">includes/css/aaron_test.css</xsl:vari
able>
<xsl:variable name="ueNECSS"
select="'includes/css/aaron_test.css'">includes/css/aaron_test.css</xsl:vari
able>
   
<!--Aaron test stuff for css ends -->
    
<!--Aaron HTML stuff one version commented out -->
 
<!-- 
<xsl:template match="xhtml:table | xhtml:TABLE | xhtml:td | xhtml:TD |
xhtml:th | xhtml:TH | xhtml:tr | xhtml:TR">
    <xsl:choose>
    <xsl:when test="*">
        <p><xsl:value-of select="*"/></p>
    </xsl:when>
    </xsl:choose>
</xsl:template> 
--> 
    
<xsl:template match="xhtml:table">
 <xsl:value-of select="."/>
</xsl:template>    
      
<!--Aaron HTML stuff ends -->
    
<xsl:template match="xhtml:img">
    <xsl:choose>
    <xsl:when test="@alt">
           <xsl:value-of select="@alt"/>
    </xsl:when>
    <xsl:otherwise>
        
           
    </xsl:otherwise>
    </xsl:choose>
</xsl:template>


<xsl:template match="xhtml:object">
    <xsl:choose>
    <xsl:when test="@id">
           [<xsl:value-of select="@id"/> not available in text-only mode.]
    </xsl:when>
    <xsl:otherwise>
           [Object not available in text-only mode.]
    </xsl:otherwise>
    </xsl:choose>
</xsl:template>


<xsl:template match="xhtml:body">

    <xsl:copy>
        <xsl:copy-of select="@*"/>
        
        
    <p>University of the West of England, Bristol | <a
href="http://www.uwe.ac.uk">Home</a></p>
    <br/>
    <table width="100%" cellpadding="0" cellspacing="0">
    <tr>
        <td valign="top" align="left" id="content">
    <a name="top"></a>
    <br /><br />
    
        <xsl:apply-templates />

    <br />

    </td>
    </tr>
    <tr>
    <td id="footer">
    <xsl:for-each select="$links/collection/sidebar/sectionheading/heading">
        <b><xsl:value-of select="title"/></b> :
        <xsl:apply-templates select="link"/>
    </xsl:for-each>
    
    <xsl:for-each select="$links/collection/sidebar/sectionheading">
        <b><xsl:value-of select="title"/></b> :
            <xsl:apply-templates select="link"/>
    </xsl:for-each>
    
                   
         
    
    
    <p>Page last updated <xsl:value-of select="$ueLastUpdate"/><br/>
    )<xsl:value-of select="$ueYear"/> University of the West of England,
Bristol<br/>       
    <a accesskey="8"
href="http://www.uwe.ac.uk/info/termsAndConditions.shtml">Terms &amp;
Conditions </a> | 
    <a href="http://www.uwe.ac.uk/info/privacy.shtml">Privacy Policy </a> |
    <a accesskey="0"
href="http://www.uwe.ac.uk/info/accessibility.shtml">Accessibility </a> |
    <a accesskey="9"
href="http://www.uwe.ac.uk/help/feedback.shtml">Feedback </a></p>
        
                
                <p>
                <a href="http://www.uwe.ac.uk/textOnly.php">Graphical
version</a> |      
                <a href="{ueSelf}?uePrinter=1" target="_blank">Printer
friendly version</a><br/>
                <xsl:text>Contrast | </xsl:text>
                <xsl:choose>
                   
                    <xsl:when test="$ueContrast = 'HC'">
                        <a
href="http://www.uwe.ac.uk/textOnly.php?contrast=off">Standard</a> |
                        <a
href="http://www.uwe.ac.uk/textOnly.php?contrast=muted">Low</a> |
                    </xsl:when>
                   
                    <xsl:when test="$ueContrast = 'LC'">
                        <a
href="http://www.uwe.ac.uk/textOnly.php?contrast=off">Standard</a> |
                        <a
href="http://www.uwe.ac.uk/textOnly.php?contrast=high">High</a> |
                    </xsl:when>
                
                    <xsl:when test="$ueContrast = 'NC'">
                        <a
href="http://www.uwe.ac.uk/textOnly.php?contrast=high">High</a> |
                        <a
href="http://www.uwe.ac.uk/textOnly.php?contrast=muted">Low</a> |
                    </xsl:when>
                </xsl:choose>
                
        
    </p> 
    </td></tr></table>
</xsl:copy>
</xsl:template>

<xsl:template match="link">
    
    <a href="{url}">
        <!-- Handle the optional title node -->
        <xsl:attribute name="title">
            <xsl:choose>
                <xsl:when test="description !=''"><xsl:value-of
select="description" /></xsl:when>
            </xsl:choose>
                   
        </xsl:attribute>
                
        <xsl:apply-templates select="link/link"/>
                   
        <xsl:value-of select="title"/></a>


</xsl:template>

</xsl:stylesheet>

......................................................................

Aaron Johnson
GUI / XSLT development
Academic Technologies Group [ATG]
University of the West of England

ext: 81051
t: 0117 3281051 
www: http://atg.uwe.ac.uk/aaron
e: aaron2.johnson@xxxxxxxxx
......................................................................

......................................................................

SECURITY POLICY:

Please note that ATG will only accept
e-mail attachments in the following
formats:

.doc,.gif,.jpg,.mdb,.png,.xls,.zip,.psd

...as a mac user I will accept files
compressed using Dropstuff.
......................................................................

This communication is intended solely
for the use of the individual(s) to whom
it is addressed. Any opinions presented
are those of the author and do not
necessarily represent the University of
the West of England, Bristol.
......................................................................



> From: David Carlisle <davidc@xxxxxxxxx>
> Reply-To: <xsl-list@xxxxxxxxxxxxxxxxxxxxxx>
> Date: Tue, 19 Oct 2004 16:31:38 +0100
> To: <xsl-list@xxxxxxxxxxxxxxxxxxxxxx>
> Subject: Re:  Stripping or converting HTML tags
> 
> 
>> Is that still applicable if there is CSS controlling the output of <p>?
> 
> yes.
> 
> You asked that you get just the text of the table so that will convert
> 
> <table>
> <tbody>
> <tr>
> <td>this</td><td><b>and</b> <em>this</em></td>
> </tr>
> <tr>
> <td>this</td><td><b>and</b> <em>this</em></td>
> </tr>
> </tbody>
> </table>
> 
> to
> <p>
> 
> 
> thisand this
> 
> 
> thisand this
> 
> 
> </p>
> 
> so clearly there is no way to css style the words within the paragraph.
> 
> If that isn't the transformation that you want then you need to describe
> what you do want.
> 
> David
> 
> ________________________________________________________________________
> This e-mail has been scanned for all viruses by Star. The
> service is powered by MessageLabs. For more information on a proactive
> anti-virus service working around the clock, around the globe, visit:
> http://www.star.net.uk
> ________________________________________________________________________
> 
> 
> 
> This incoming email to UWE has been independently scanned for viruses and any
> virus detected has been removed using McAfee anti-virus software
> 



This email has been independently scanned for viruses and any virus detected has been removed using McAfee anti-virus software

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.