xsl-list
[Top] [All Lists]

RE: Newbie Q: Why are element contents being passed through?

2003-04-09 23:59:41
Hi,

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.

In your stylesheet you have

  <xsl:apply-templates/>

which means

  <xsl:apply-templates select="node()"/>

see <http://www.w3.org/tr/xslt#section-Applying-Template-Rules>. Thus, you're 
also processing text nodes--select only the nodes you want to process.

Still, that's not the problem here, but rather that you have template only for 
"rateshop" and "form" elements. In the template for "form" you process all 
child nodes, and in the absence of templates for the child elements of form, 
the build-in templates kick in--see <http://www.w3.org/tr/xslt#built-in-rule>. 
The build in templates output all descendant text nodes in your case.

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!)

Strip the unneeded whitespace from the source tree and add indentation to the 
output--see <http://www.w3.org/TR/xslt#strip> and 
<http://www.w3.org/TR/xslt#output>.

Cheers,

Jarno - C-Drone Defect: Psycho2vii

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