Subject: Re: [xsl] Selectively convert Attributes to child Elements From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx> Date: Mon, 18 May 2009 20:45:38 -0400 |
The current INPUT XSL file (which I found & tweaked from http://www.biglist.com/lists/lists.mulberrytech.com/xsl-list/archives/200011/msg00567.html) doesn't output the ROOT element,
and currently strips all attributes (it only outputs the parent element if it strips the attribute). With the exception of the above attributes being output as child elements, I want to preserve the current XML document.
T:\ftemp>type maestro.xml <?xml version="1.0" encoding="UTF-8"?> <buckets siteid="mysiteid" version="1.0"> <bucket priority="4" bucketid="12348" title="Sports" displaytitle="Sports" link="/sections/sports/" target="_blank" display="1"> <nav> <item priority="1" title="Baseball" displaytitle="Baseball" link="/sections/sports/baseball/" description="Baseball 411" display="1"/> <item priority="2" title="Football" displaytitle="Football" link="/sections/sports/football/" description="" display="1"/> </nav> <contentInclude priority="1" max="3" display="1"> <item catid="2345" catname="Sports" prefix="" display="1"/> </contentInclude> <contentInclude type="daytime" priority="2" max="2" display="1"> <item catname="sports" display="1"/> </contentInclude> <contentInclude type="blog" priority="3" max="2" display="1"> <item catname="coolblog" prefix="Cool: " display="1"/> <item catname="soundblog" prefix="Sounds: " display="1"/> </contentInclude> <bucketBottomLink title="More Sports »" link="/sections/entertainment/" display="1"/> </bucket> <bucket priority="3" bucketid="12347" title="Promotions" displaytitle="" description="This is the Promotions bucket" link="" display="1" tags="promos,promotions,nonpublic"> <contentInclude priority="1" display="1"> <item catid="5678" catname="Promos" prefix="" display="1"/> </contentInclude> </bucket> <bucketLists> <bucketList priority="4" bucketListid="4" location="homepage" title="Entertainment List" displaytitle="Entertainment Junkie" display="1" tags="entertainment,fun"> <bucketListItem priority="1" bucketid="34572" title="Entertainment" display="1"/> <bucketListItem priority="5" bucketid="34576" type="blog" title="artsblog" items="7" display="1"/> </bucketList> <bucketList priority="5" bucketListid="5" location="homepage" title="Nerd" displaytitle="Nerd's List of Lists" display="1" tags="tech,technology,gadgets,nerd,geek"> <bucketListItem priority="1" bucketid="34577" title="Science & Technology" display="1"/> <bucketListItem priority="4" bucketid="34582" type="blog" title="nerdblog" items="7" display="1"/> </bucketList> </bucketLists> </buckets>
<xsl:template match="*"> <xsl:copy> <xsl:apply-templates select="@*" mode="preserve"/> <xsl:apply-templates select="@*|node()"/> </xsl:copy> </xsl:template>
<!--handle attributes at the time they are being preserved--> <xsl:template mode="preserve" match="@title|@displaytitle|@description| @catname|@prefix|@text"/>
<xsl:template mode="preserve" match="@*"> <xsl:copy/> </xsl:template>
<!--handle attributes at the time they are being converted--> <xsl:template match="@title|@displaytitle|@description| @catname|@prefix|@text"> <xsl:for-each select="@*"> <xsl:element name="{name()}"> <xsl:value-of select="."/> </xsl:element> </xsl:for-each> </xsl:template>
-- XSLT/XSL-FO/XQuery hands-on training - Los Angeles, USA 2009-06-08 Crane Softwrights Ltd. http://www.CraneSoftwrights.com/s/ Training tools: Comprehensive interactive XSLT/XPath 1.0/2.0 video Video lesson: http://www.youtube.com/watch?v=PrNjJCh7Ppg&fmt=18 Video overview: http://www.youtube.com/watch?v=VTiodiij6gE&fmt=18 G. Ken Holman mailto:gkholman@xxxxxxxxxxxxxxxxxxxx Male Cancer Awareness Nov'07 http://www.CraneSoftwrights.com/s/bc Legal business disclaimers: http://www.CraneSoftwrights.com/legal
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] Selectively convert Attribute, The Web Maestro | Thread | Re: [xsl] Selectively convert Attri, G. Ken Holman |
[xsl] Selectively convert Attribute, The Web Maestro | Date | Re: [xsl] Selectively convert Attri, G. Ken Holman |
Month |