[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] How to "flatten" an 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
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|