[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

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
input document
Hi,
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 :

	<X>
	  <Y>
	    <Z/>
	  </Y>
	</X>

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

	<X>
	  <ref type="Y">
	</X>
	<Y>
	  <ref type="Z">
	</Y>
	<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="*">
ref
<xsl:attribute name="type">
<xsl:value-of select=".">
</xsl:attribute>

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

<xsl:apply-templates/>
</xsl:template>


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.

Thanks,

Gordon


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



Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.