xsl-list
[Top] [All Lists]

RE: Re: Group various elements with empty tags (flat XML structure to hierarcial XML)

2005-01-07 12:07:00
-----Original Message-----
From:     M Glenties <mglenties(_at_)hotmail(_dot_)com>

Thank you everyone for your posts.

The solution from Charles Knell is close to what I need. The output has 2 
problems:

1. The attribute xmlns:sql="urn:schemas-microsoft-com:xml-sql" is now 
included with each element.
(FYI, the flat xml document I start with is created from an sql "for xml 
auto" command in a template file launched by VB).

From XSLT Programmer's Reference, 2nd Ed., page 309, "So if there are 
namespaces you don't want in the output tree, you can specify them in the 
exclude-result-prefixes attribute of the <xsl:stylesheet> element."

2. The data grouped in the new tags repeats after the tag (except for the 
first element in the group).
For example, (snippet):
-------------------------------------
<ADDRESS>
    <street xmlns:sql="urn:schemas-microsoft-com:xml-sql">35 Main 
Street</street>
    <city xmlns:sql="urn:schemas-microsoft-com:xml-sql">Moosejaw</city>
    <country 
xmlns:sql="urn:schemas-microsoft-com:xml-sql"y>Saskatchewan</country>
     <postal_code 
xmlns:sql="urn:schemas-microsoft-com:xml-sql">TOEOPO</postal_code>
</ADDRESS>
MoosejawSaskatchewanTOEOPO
------------------------------------

That's because you removed the template,
<xsl:template 
match="initial|lastname|city|country|postal_code|amount1|amount2|amount3" />.

The point of it is to suppress the normal output of the content of the 
elements. I created this template to handle two kinds of elements from the 
input document: 1) Those that were shown as not to be output by examining the 
sample output document and 2) those elements that were handled explicitly 
elsewhere, specifically, those elements that are handled in the templates that 
create the <NAME> and <ADDRESS> elements in the output document.

the following does not produce output:
<xsl:template 
match="initial|lastname|city|country|postal_code|amount1|amount2|amount3" />

At the risk of mystifying any readers who have never seen the "Seinfeld" 
television show, "Exactly!"
-- 
Charles Knell
cknell(_at_)onebox(_dot_)com - email


--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--