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

Subject: RE: [xsl] Newbie Q: Why are element contents being passed through?
From: "Passin, Tom" <tpassin@xxxxxxxxxxxx>
Date: Thu, 10 Apr 2003 10:28:10 -0400
[Elijah Mori]

> 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.
> 

I hope that your xml sample is not what you actually tested, because it
is not well-formed.  Assuming that the missing "</input>' has been
restored, you are seeing the results of the build-in default template
getting applied.  This is happening in the template matching "form".
You have <xsl:apply-templates/> in there, but there are no templates
that match anything.  The processor therefore applies the built-in
template, which just gets the text content of the elements it operates
on.

You canverify this behavior by supplying a template that matches any
element and does nothing:

<xsl:apply-templates match='*'/>

However, this is probably not what you want because you want to process
the child elements of the form.  You probably were thinking of using
xsl:copy-of, but you better not because your input document does not
contain proper html form elements.  You have <input type='select'>...,
bu it is supposed to be a <select .... ...> element instead.  You could
write a template to make this change or you could change the source
format.

Cheers,

Tom P

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


Current Thread