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: Selective output of half a tag?


> to explain properly) above is to take a series of <foo/> tags

Try to avoid using the word "tag". If you think in terms of tags then
you get into precisely the problems you describe. XSLT does not deal
with tags at all, all tags (that is linerised XML markup)  have been
processed by an XML parser before XSLT even starts. XSLT works on trees
it does not see tags in teh input, nor can it directly create tags in
the output.

You can talk about a start tag without an end tag, as they are just
two strings but you can't have half a node in a tree. If you think in
terms of tree transformations then XSLT becomes a lot easier to
understand.

Your problem 


> Hence the need to determine if a <foo/> is the last in the group of
> <foo/>'s, so it can append a </mytag>.

No. wrong way to describe the problem. Your first description was
better:

> take a series of <foo/> tags in the
> source, convert them all to <bar/> in the output, and then wrap the
> group of <bar/> up in <mytag/>.

but again you should not think in terms of tags

take a series of foo eleemnts in the
source, convert them all to bar elements in the output, and then wrap the
group of bar up in mytag element:


<xsl:template match="parent-of-foo">
....
<mytag>
 <xsl:template select="foo"/>
</mytag>
....
</xsl:template>


<xsl:template match="foo">
<bar>
<xsl;apply-templates/>
</bar>
</xsl:template>



David

_____________________________________________________________________
This message has been checked for all known viruses by Star Internet
delivered through the MessageLabs Virus Scanning Service. For further
information visit http://www.star.net.uk/stats.asp or alternatively call
Star Internet for details on the Virus Scanning Service.

 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]