Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 19th, 2005, 08:46 AM
Registered User
 
Join Date: Sep 2005
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Filter HTML Code in XSL

Anyone have an example on how to convert HTML code back to charatcter in an XSL?

For example:

changing: "capitol'
into: "capitol'

or

changing:
<p>Page 12
<p>
<p> CONGRESS KNEW PAROCHIALISM
would trump national security in deciding

into:
Page 12

CONGRESS KNEW PAROCHIALISM
would trump national security in deciding

I want to automate data entry into my Filemaker Pro 7 database, and I can get all the data, but it still has HTML code leftover. Any help is greatly appreciated! Here's what I have so far:

<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:output indent="yes" method="xml"/>
    <xsl:template match="newsclips">
        <FMPXMLRESULT xmlns="http:www.filemaker.com/fmpxmlresult">
            <ERRORCODE>0</ERRORCODE>
            <PRODUCT BUILD="11-05-2003" NAME="Filemaker Pro" VERSION="7.0v1"/>
            <DATABASE DATEFORMAT="M/d/yyyy" LAYOUT="" NAME="test.fp7" RECORDS="{@count}" TIMEFORMAT="h:mm:ss a"/>

            <METADATA>
                <FIELD EMPTYOK="YES" MAXREPEAT="1" NAME="clipid" TYPE="TEXT"/>
                <FIELD EMPTYOK="YES" MAXREPEAT="1" NAME="headline" TYPE="TEXT"/>
                <FIELD EMPTYOK="YES" MAXREPEAT="1" NAME="link" TYPE="TEXT"/>
                <FIELD EMPTYOK="YES" MAXREPEAT="1" NAME="registration" TYPE="TEXT"/>
                <FIELD EMPTYOK="YES" MAXREPEAT="1" NAME="clipdate" TYPE="TEXT"/>
                <FIELD EMPTYOK="YES" MAXREPEAT="1" NAME="cliptime" TYPE="TEXT"/>
                <FIELD EMPTYOK="YES" MAXREPEAT="1" NAME="cliprating" TYPE="TEXT"/>
                <FIELD EMPTYOK="YES" MAXREPEAT="1" NAME="source" TYPE="TEXT"/>
                <FIELD EMPTYOK="YES" MAXREPEAT="1" NAME="sourceid" TYPE="TEXT"/>
                <FIELD EMPTYOK="YES" MAXREPEAT="1" NAME="state" TYPE="TEXT"/>
                <FIELD EMPTYOK="YES" MAXREPEAT="1" NAME="country" TYPE="TEXT"/>
                <FIELD EMPTYOK="YES" MAXREPEAT="1" NAME="circulation" TYPE="TEXT"/>
                <FIELD EMPTYOK="YES" MAXREPEAT="1" NAME="byline" TYPE="TEXT"/>
                <FIELD EMPTYOK="YES" MAXREPEAT="1" NAME="sourcelanguage" TYPE="TEXT"/>
                <FIELD EMPTYOK="YES" MAXREPEAT="1" NAME="keywordfound" TYPE="TEXT"/>
                <FIELD EMPTYOK="YES" MAXREPEAT="1" NAME="abstract" TYPE="TEXT"/>
            </METADATA>

            <RESULTSET FOUND="{@count}">
                <xsl:for-each select="newsclip">
                    <ROW MODID="0" RECORDID="{position()}">
                        <COL><DATA><xsl:value-of select="clipid"/></DATA></COL>
                        <COL><DATA><xsl:value-of select="headline"/></DATA></COL>
                        <COL><DATA><xsl:value-of select="link"/></DATA></COL>
                        <COL><DATA><xsl:value-of select="registration"/></DATA></COL>
                        <COL><DATA><xsl:value-of select="clipdate"/></DATA></COL>
                        <COL><DATA><xsl:value-of select="cliptime"/></DATA></COL>
                        <COL><DATA><xsl:value-of select="cliprating"/></DATA></COL>
                        <COL><DATA><xsl:value-of select="source"/></DATA></COL>
                        <COL><DATA><xsl:value-of select="sourceid"/></DATA></COL>
                        <COL><DATA><xsl:value-of select="state"/></DATA></COL>
                        <COL><DATA><xsl:value-of select="country"/></DATA></COL>
                        <COL><DATA><xsl:value-of select="circulation"/></DATA></COL>
                        <COL><DATA><xsl:value-of select="byline"/></DATA></COL>
                        <COL><DATA><xsl:value-of select="sourcelanguage"/></DATA></COL>
                        <COL><DATA><xsl:value-of select="keywordfound"/></DATA></COL>
                        <COL><DATA><xsl:value-of select="abstract"/></DATA></COL>

                    </ROW>
                </xsl:for-each>
            </RESULTSET>
        </FMPXMLRESULT>
    </xsl:template>
</xsl:stylesheet>

Thanks,

-Teo

 
Old September 19th, 2005, 09:07 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

I suspect that your XML source contains escaped HTML markup. This is always a bad idea. Because the markup is disguised by escaping it, it won't be recognized by the XML parser: you have to extract it as text and put it back through another stage of parsing, e.g. using an extension like saxon:parse().

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
 
Old September 24th, 2005, 09:19 AM
Registered User
 
Join Date: Sep 2005
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks Michael,

The XML feed is custom produced by an agency for the people I work for. Should I request the XML be cleaned up at the source if I can? If not, how would I make use of saxon:parse? Do I need to download the opensource version of saxon from sourceforge? I was looking at w3 and there was a section on disabling output escaping, is this a bad idea?

Thanks again!

-Teo






Similar Threads
Thread Thread Starter Forum Replies Last Post
HTML code from XML to display using XSL koenige XSLT 6 October 27th, 2008 08:11 AM
xml to html with xsl boblavinsky XSLT 4 January 5th, 2007 05:30 AM
XSL table to HTML ayamas XSLT 10 September 11th, 2006 06:45 AM
Help with code to filter through database. malhyp Dreamweaver (all versions) 4 May 27th, 2006 02:44 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.