How to "flatten" an input document?

Subject: How to "flatten" an input document?
From: Gordon Vidaver <gvidaver@xxxxxxx>
Date: Tue, 13 Jun 2000 22:17:43 -0400
I'm new to XSL so perhaps this is an easy problem for someone more experienced.

I have an input document that's a set of nested tags :


And I want to generate an output document that looks like this:

	  <ref type="Y">
	  <ref type="Z">

Essentially "flattening" the original document. Instead of nested tags, there should be just references to other tags that are children of the root.

This does not seem to be possible in XSL, since there doesn't seem to be any way to output two elements at different places in the output tree as a result of one rule. Modes seem to let you have multiple matching rules, but they can only produce sibling elements in the output.

There's also seemingly no way to put an element at an arbitrary place in the output tree. For instance, if I could somehow have a command that put elements at the root of the output tree, I could do something like this:

<xsl:template match="*">
<xsl:for-each select="*">
<xsl:attribute name="type">
<xsl:value-of select=".">

<xsl:put-element-at select-in-output="/"> <-- this is my imagined command -->
<xsl:copy-of select=".">


Is this type of thing possible in XSL? Is there something I'm missing? Or do I need to use an XSL extension?

Any help anyone can provide would be most appreciated.



XSL-List info and archive:

Current Thread