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

Re: Newbie Q: Why are element contents being passed th

Subject: Re: Newbie Q: Why are element contents being passed through?
From: "Dimitre Novatchev" <dnovatchev@xxxxxxxxx>
Date: Thu, 10 Apr 2003 07:09:04 +0200
option stylesheet
Read about the "default rules" or "built-in template rules".

The XSLT 1.0 spec (http://www.w3.org/TR/xslt#built-in-rule) says:

"There is a built-in template rule to allow recursive processing to continue
in the absence of a successful pattern match by an explicit template rule in
the stylesheet"

and

"There is also a built-in template rule for text and attribute nodes that
copies text through:
<xsl:template match="text()|@*">
  <xsl:value-of select="."/>
</xsl:template>"Most probably you have an xsl:apply-templates in your code
against a node-set some of whose nodes are not matched by templates in your
code. Then the built-in templates are instantiated/applied by the XSLT
processor. This is done in a recursive manner until text nodes are reached,
at which point the built-in template rule (for text and attribute nodes)
above copies the contents of the text nodes to the output.


=====
Cheers,

Dimitre Novatchev.
http://fxsl.sourceforge.net/ -- the home of FXSL



"Elijah Mori" <elijah@xxxxxxxxxxx> wrote in message
news:3E94E9D3.8080305@xxxxxxxxxxxxxx
> Many apologies if this is a FAQ; I didn't find it when looking, but the
> FAQ at dpawson.co.uk is massive and I may have missed it.
>
> I have an xml source doc which I want to turn into an xhtml document
> with a form, inputs, labels and so forth. What is happening is that the
> contents of the elements in the xml document are turning up in the
> output and I can't understand why. I have simplified the xml and the xsl
> until there is almost nothing happening, and the element contents still
> come through.
>
> What can I do? Any help will be appreciated. (And if there is any way to
> deal with the bizarre spacing in the output document that would be
> appreciated too!)
>
> Best regards
> Eli
>
>
> Here are the two input docs and the output.
> xml:
> <?xml version="1.0"?>
> <form name="rateshop" action="backend/update-shop.php">
>    <shopid>
>    <label>Shop ID</label>
>      <input type="hidden"/>
>    </shopid>
>    <name>
>    <label>Name</label>
>      <input type="text"/>
>
>    </name>
>    <regionid>
>    <label>Region</label>
>      <input type="select" option="singlechoice"><option
> value="1">Hokkaido</option><option value="2">Aomori</option><option
> value="3">Iwate</option><option value="4">Miyagi</option><option
> value="5">Yamagata</option></input>
>
>    </regionid>
>    <city>
>    <label>City</label>
>      <input type="text"/>
>    </city>
>    <blockaddress>
>    <label>Block Address</label>
>      <input type="text"/>
>
>    </blockaddress>
>    <phonenumber>
>    <label>Phone Number</label>
>      <input type="text"/>
>    </phonenumber>
>    <openingtime>
>    <label>Opening Time</label>
>      <input type="select" option="singlechoice"><option
> value="10:00">10:00</option><option value="11:00">11:00</option><option
> value="12:00">12:00</option><option value="13:00">13:00</option><option
> value="14:00">14:00</option><option value="15:00">15:00</option>
>    </openingtime>
>    <closingtime>
>    <label>Closing Time</label>
>      <input type="select" option="singlechoice"><option
> value="00:00">00:00</option><option value="01:00">01:00</option><option
> value="02:00">02:00</option><option value="03:00">03:00</option><option
> value="04:00">04:00</option><option value="05:00">05:00</option><option
> value="23:00">23:00</option></input>
>
>    </closingtime>
>    <rating>
>    <label>Rating</label>
>      <input type="select" option="singlechoice">
>        <option>1</option>
>        <option>2</option>
>        <option>3</option>
>
>        <option>4</option>
>        <option>5</option>
>        <option>6</option>
>        <option>7</option>
>        <option>8</option>
>        <option>9</option>
>
>        <option>10</option>
>      </input>
>    </rating>
>    <userid>
>    <label>User ID</label>
>      <input id="userid" type="hidden"/>
>    </userid>
> </form>
>
>
> xslt:
> <?xml version="1.0"?>
> <xsl:stylesheet version =' 1.0'
> xmlns:xsl='http://www.w3.org/1999/XSL/Transform'>
>    <xsl:output
>      doctype-system='http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd'
>      doctype-public='-//W3C//DTD XHTML 1.1//EN'
>      method='xml'
>      />
>
>    <xsl:output
>      encoding="iso-8859-1"
>      />
>
>      <xsl:template match='/'>
>        <html xmlns='http://www.w3.org/1999/xhtml'>
>          <head>
>            <title>Shop</title>
>            <link href='css/site.css' type='text/css' rel='stylesheet'/>
>          </head>
>          <body>
>            <xsl:apply-templates/>
>          </body>
>        </html>
>      </xsl:template>
>
>      <xsl:template match='form'>
>        <form>
>          <xsl:copy-of select='@*'/>
>          <xsl:apply-templates/>
>        </form>
>      </xsl:template>
>
> </xsl:stylesheet>
>
> output:
> <?xml version="1.0" encoding="iso-8859-1"?>
> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
> "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
> <html xmlns="http://www.w3.org/1999/xhtml">
>    <head>
>      <title>Shop</title>
>      <link href="css/site.css" type="text/css" rel="stylesheet"/>
>
>    </head>
>    <body>
>      <form name="rateshop" action="backend/update-shop.php">
>
>    Shop ID
>
>
>
>    Name
>
>
>
>    Region
>      HokkaidoAomoriIwateMiyagiYamagata
>
>
>    City
>
>
>
>    Block Address
>
>
>
>    Phone Number
>
>
>
>    Opening Time
>      10:0011:0012:0013:0014:0015:00
>
>
>    Closing Time
>      00:0001:0002:0003:0004:0005:0023:00
>
>
>    Rating
>
>        1
>        2
>        3
>        4
>        5
>        6
>        7
>        8
>        9
>        10
>
>
>
>    User ID
>
>
> </form>
>    </body>
> </html>
>
>
>  XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
>
>




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


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.