Subject: [xsl] De-Normalizing (or Flatten) a Node Tree From: Davis David J CONT CNIN <davis_david@xxxxxxxxxxxxxx> Date: Wed, 12 Mar 2003 17:16:14 -0500 |
I have written the following transformation to create a xml file to bulk load documents into a document management system. When I attempted to load the file the vendor informed me that their product would not support a nested structure. Can You advise me on how I might de-normalize or flatten this node tree to a sequential set of tags in a first to last order that looks like this: Desired XML Output <msiimprt> <object name="MM BPR" parent="Enterprise:CDMS Help and Information:Folder Templates:" description="CDMS Import Project" type="0" subtype="0"> <category category="Livelink Categories:Migration"> </object> <object name="MM-A--Scope Planning" parent="Enterprise:CDMS Help and Information:Folder Templates:MM BPR" description="CDMS Import Project" type="0" subtype="0"> <category category="Livelink Categories:Migration"> </object> <object name="MM-A-1--Presentations" parent="Enterprise:CDMS Help and Information:Folder Templates:MM BPR:MM-A--Scope Planning" description="CDMS Import Project" type="0" subtype="0"> <category category="Livelink Categories:Migration"> </category> </object> ......... </msiimprt> Thank You in Advance for your help in this matter, David Davis XSLT Transformation <?xml version ="1.0"?> <xsl:transform version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="xml" encoding="ISO-8859-1"/> <xsl:variable name="slash"><xsl:text>\</xsl:text></xsl:variable> <xsl:template match="involume"> <msiimprt> <xsl:apply-templates select="*"/> </msiimprt> </xsl:template> <xsl:template match="dir"> <object name="{./name}" parent="Enterprise:CDMS Help and Information:Folder Templates:{translate(substring-after(substring-before(./fullname, concat($slash,./name)), 'v:\'),'\',':')}" description="CDMS Import Project" type="0" subtype="0"> <xsl:element name="category"> <xsl:attribute name="category"> <xsl:text>Livelink Categories:Migration</xsl:text> </xsl:attribute> <xsl:apply-templates select="*"/> </xsl:element> </object> </xsl:template> <xsl:template match="file"> <object name="{./name}" parent="Enterprise:CDMS Help and Information:Folder Templates:{translate(substring-after(substring-before(./fullname, concat($slash,./name)), 'v:\'),'\',':')}" description="CDMS Import Project" type="0" subtype="144"> <xsl:element name="category"> <xsl:attribute name="category"> <xsl:text>Livelink Categories:Migration</xsl:text> </xsl:attribute> <xsl:apply-templates select="*"/> </xsl:element> </object> </xsl:template> Input XML <?xml version="1.0" encoding="ISO-8859-1" ?> <!-- Created with Catalogue version 4.1c [Soft Experience] --> <involume name="" filesystem="NTFS" dategeneration = "November 29, 2002 14:08"> <dir> <name>MM BPR</name><fullname>v:\MM BPR</fullname> <dir> <name>MM-A--Scope Planning</name><fullname>v:\MM BPR\MM-A--Scope Planning</fullname> <dir> <name>MM-A-1--Presentations</name><fullname>v:\MM BPR\MM-A--Scope Planning\MM-A-1--Presentations</fullname> </dir> <dir> <name>MM-A-2--POAM-Roles-Resources</name><fullname>v:\MM BPR\MM-A--Scope Planning\MM-A-2--POAM-Roles-Resources</fullname> <dir> <name>MM-A-2-1--Status Reports</name><fullname>v:\MM BPR\MM-A--Scope Planning\MM-A-2--POAM-Roles-Resources\MM-A-2-1--Status Reports</fullname> </dir> </dir> <dir> <name>MM-A-3--Refs-Misc</name><fullname>v:\MM BPR\MM-A--Scope Planning\MM-A-3--Refs-Misc</fullname> </dir> <dir> <name>MM-A-4--Minutes</name><fullname>v:\MM BPR\MM-A--Scope Planning\MM-A-4--Minutes</fullname> </dir> <dir> <name>MM-A-5--Communication Plan</name><fullname>v:\MM BPR\MM-A--Scope Planning\MM-A-5--Communication Plan</fullname> </dir> </dir> <dir> <name>MM-B--AS-IS</name><fullname>v:\MM BPR\MM-B--AS-IS</fullname> <dir> <name>MM-B-1--Presentations</name><fullname>v:\MM BPR\MM-B--AS-IS\MM-B-1--Presentations</fullname> <file> <name>mm to-be.ppt</name><fullname>v:\MM BPR\MM-B--AS-IS\MM-B-1--Presentations\mm to-be.ppt</fullname><shortname>MMTO-B~1.PPT</shortname> <extension>ppt</extension> <size>196608</size> <datetime> <creation>1998/11/10 09:37</creation> <lastsave>1998/12/10 16:37</lastsave> <lastaccess>2002/11/23 07:49</lastaccess> <lastprint>1998/12/10 14:40</lastprint> <totaledit>37:01</totaledit> </datetime> <summary><application>PowerPoint</application><title>No Slide Title</title><author>Joshua J. Greenlee</author><template>C:\Program Files\Microsoft Office\Templates\Presentation Designs\AA Presentation Template.pot</template><lastauthor>Rebecca Ruselink</lastauthor><revisions>65</revisions><paragraphs>308</paragraphs><w ords>1225</words><notes>2</notes><slides>34</slides><company>Andersen Worldwide</company></summary> </file> </dir> Current XML Output <?xml version="1.0" encoding="ISO-8859-1"?> <msiimprt> <object name="MM BPR" parent="Enterprise:CDMS Help and Information:Folder Templates:" description="CDMS Import Project" type="0" subtype="0"> <category category="Livelink Categories:Migration"> <object name="MM-A--Scope Planning" parent="Enterprise:CDMS Help and Information:Folder Templates:MM BPR" description="CDMS Import Project" type="0" subtype="0"> <category category="Livelink Categories:Migration"> <object name="MM-A-1--Presentations" parent="Enterprise:CDMS Help and Information:Folder Templates:MM BPR:MM-A--Scope Planning" description="CDMS Import Project" type="0" subtype="0"> <category category="Livelink Categories:Migration"> </category> </object> <object name="MM-A-2--POAM-Roles-Resources" parent="Enterprise:CDMS Help and Information:Folder Templates:MM BPR:MM-A--Scope Planning" description="CDMS Import Project" type="0" subtype="0"><category category="Livelink Categories:Migration"> <object name="MM-A-2-1--Status Reports" parent="Enterprise:CDMS Help and Information:Folder Templates:MM BPR:MM-A--Scope ........ XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] Re: Re: Re: dynamic XPath?, Dimitre Novatchev | Thread | [xsl] comparing timestamps, walter . crockett |
RE: [xsl] Comparing two xml documen, Lars Huttar | Date | Re: [xsl] dynamic XPath?, Steve Ball |
Month |