This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: stupid newbie question


I pretty sure this is in fact a FAQ, but I'm in a good mood :-)

Try this:
XML:
<document>
<title>title</title>
<drawing output="filename.jpg"/>
<p>paragraph</p>
</document>

XSLT:
<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
    <xsl:template match="/">
       <xsl:apply-templates />
    </xsl:template>


    <!-- default behaviour:
    <xsl:template match="*">
                 <xsl:apply-templates/>
    </xsl:template>

         and with templates al you do is change that def. behaviour,
         so when you only specify a template for that certain element, all
         other will be processed according to the above template..

         more or less anyway...
         :-)
    -->


    <xsl:template match="*">
    <!-- try and copy your elements into your output: changing the 
behaviour for all elements-->
         <xsl:copy>
                 <xsl:copy-of select="@*"/>
                 <xsl:apply-templates/>
         </xsl:copy>
    </xsl:template>

    <xsl:template match="drawing">
    <!-- this element should have specific care,
    because this template is more specifiec than the above one, this one
    gets precedence, and therefore you can change the behaviour for this 
specific element-->
    <img src="{@output}"/>
    </xsl:template>
</xsl:stylesheet>

At 04:57 AM 12/4/01 -0500, you wrote:
>hey all -
>
>i'm new to the list and XSL so this might seem like a silly question
>(and maybe one that's already been asked a dozen times)...
>
>i need to apply a stylesheet that goes in and changes only one tag in
>my document.  specifically
>
>         <drawing output="filename.jpg">
>
>needs to become
>
>         <img src="filename.jpg">
>
>like in html.  my stylesheet has one single template that does this,
>but when i apply it, ALL of the other tags in the document disappear.
>i assume that without a template for a specific tag, my transformer is
>mapping the other tags to nothing at all.  is there a simple way
>around this?  or do i need to make templates for each and every tag
>that transforms them into the result document as what they were in the
>source?
>
>thanks in advance for all your help.  and apologies if i'm wasting
>everyone's time.
>
>-greg
>
>----------
>
>the poems to come are for you and for me and are not for most people.
>
>
>  XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list

Salience B.V.

Ronald Heller
Technisch Consultant

Coltbaan 27b
3439 NG Nieuwegein
Telefoon 030 60 56 675
Telefax  030 60 56 324
Website www.salience.nl
ronald@salience.nl
Mobiel   06 20 41 25 77
ICQ 135511393



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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]