xsl-list
[Top] [All Lists]

Output XML just as it is...

2004-03-02 01:32:22
Hello,

I have some XML (which is really XHTML on the inside) that I'd like to
output as an exact copy of HTML (without using CDATA).  Also, it might be
necessary to alter the SRC property of an IMG element, so would consider
some sort of IMG match and copy all properties but alter SRC.

-- also: just now starting to grasp the power of XSLT... coupled with HTML
-- another note:  in the past I struggled to understand how in XSLT you
could implement a FIND/REPLACE type functionality, well with what I've
learned as of recent, XSLT handles this quite well (if not better!!) by
implementing template matches on elements of your liking.  Now, you can't
find replace "Jones", but you are the developer... before "Jones" is part of
the output, handle it... as in, create a last name element <sur_name/> and
perform a template match against that (sorry, rambling)

Anyhow, here is a short example of some XML:

<campaign>
    <table width="100%">
        <tr><td colspan="2">You say Yes</td></tr>
        <tr><td>I say no</td>
        <td>You say goodbye</td></tr>
    </table>
    <img src="/images/some_image.gif"/>
</campaign>


I am trying to implement this from XSL like this:

<xsl:template match="/">
    <!-- reference external xml/xhtml source-->
        <xsl:variable name="c"
select="document('../campaigns/simpleone.xml')//campaign"/>
        <xsl:value-of disable-output-escaping="yes" select="$c"/>
</xsl:template>

( Returned raw text... HTML stripped )

Then I tried something like this

<xsl:template name="PREVIEW">
    <xsl:variable name="c" select="document('../campaigns/simpleone.xml')"/>
    <xsl:apply-templates select="$c"/>
</xsl:template>

<xsl:template match="*">
 <xsl:value-of select="."/>
</xsl:template>

( However, could not come up with any results, could not make a match )

And if I need to alter the SRC tag?  Could I do this:
<xsl:template match="img">
    <!-- then simply re-create img element, iterate through properties,
where property is "src" concat and add necessary full path -->
</xsl:template>

( If I do that, I don't quite understand where I would apply-templates... )

!!! Jim... many many thanks for opening up this door for me, my approach at
web development has taken yet another exciting turn !!!

Karl


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list



<Prev in Thread] Current Thread [Next in Thread>