Subject: [xsl] Re: Ways to Identify & Process Same name XML elements differently based on location in XML tree? From: "Alex S as.signup@xxxxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> Date: Fri, 27 Oct 2017 12:51:50 -0000 |
So I had no idea about this kind of processing Graydon. http://www.biglist.com/lists/lists.mulberrytech.com/xsl-list/archives/201710/ msg00024.html Is there a good article/ guide on learning how this is done? What I believe I was originally looking to having done similar in 2003/04 era was what Wendell mentioned here: http://www.biglist.com/lists/lists.mulberrytech.com/xsl-list/archives/201710/ msg00025.html "Advice to newbies and refresher-learners: go read a guide on match patterns in XSLT, including the rules on assignment of priorities (@priority) explicity or by default ...." Could you please link / point me to some as my googling is not bringing up what might have come up back in those days? Thanks, A ________________________________ From: Alex S <as.signup@xxxxxxxxxxx> Sent: Wednesday, October 25, 2017 5:34 AM To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx Subject: Ways to Identify & Process Same name XML elements differently based on location in XML tree? Some elements such as: <string> <array> <dict> appear repeatedly at multiple levels in this SB XML format, But they mean different things based on where they are located; mean different things at different locations, depths or parent/ ascendent What are the different ways I can tackle processing these elements and fix & improve my <xsl templates>? Details about the original Springboard .plist XML structure is outlined & attached below: http://iky1e.tumblr.com/post/11704062690/springboard-icon-layouts-iconstatepl ist Temporarily, to simplify Template Matches, I replaced few repeating "same name" elements with "distinct" names - Root: <plist> - remains as it is - Outer <dict> replaced by <all> - Represents all: Pages, Folders, Apps -- 1st level <array> replaced by <pages> --- 2nd level <array> replaced by <page> ----- Inner: <dict> remains same - Represents Folders inside Pages ------- <string> also means different things at different locations, depths or parent/ ascendent XSL - Leverages the modified elements to create viewable display Some Flaws/ Gaps: - Need guidance to rewrite more "Intelligent" templates without needing the above "substitutions" https://www.dropbox.com/sh/1m6qmhrrfxze5kj/AACdkK9HRQS7PXahZeX_uMC_a?dl=0 Dropbox Folder contains: Current XSLT, Original SB XML and the Modified SB XML (that works with Current XSLT). Need to figure out how to process Original SB XML with the Common Element names at varying locations. Current XSLT: <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format"> <xsl:template match="/"> <html> <head> <title>X</title> <!-- <link rel="stylesheet" href="style.css" type="text/css"></link> --> <link rel="stylesheet" href="css/style.css" type="text/css"/> </head> <body> <xsl:apply-templates/> </body> </html> </xsl:template> <xsl:template match="all"> <!-- Enter ALL <br/> --> <!-- Button Bar only --> <ul> <!-- <xsl:comment>Test Comment KC</xsl:comment><span>TEST Call KC</span> --> <xsl:call-template name="KeyCategory"/> <!-- <xsl:comment>Test Comment FSDN</xsl:comment><span>TEST Call FSDN</span> --> <!-- <xsl:call-template name="FolderStringDisplayName"></xsl:call-template> --> <xsl:apply-templates select="array"/> <!-- Apply to & Process Items under Button Bar --> </ul> <!-- Button Bar only --> <xsl:apply-templates select="pages"/> <!-- Apply to & Process Items under Pages --> </xsl:template> <xsl:template match="pages"> <xsl:comment>Enter PAGES</xsl:comment> <xsl:apply-templates/> <xsl:comment>Exit PAGES</xsl:comment> </xsl:template> <xsl:template match="page"> <xsl:comment>Enter PAGE</xsl:comment> <ul> <h2>Pg: <xsl:value-of select="./attribute::num"/> </h2> <li> <input type="checkbox"> <xsl:attribute name="checked">checked</xsl:attribute> </input> <i/> <h2>Folder 1</h2> <p>Apps 1 </p> </li> <xsl:apply-templates/> </ul> <xsl:comment>Exit PAGE</xsl:comment> </xsl:template> <xsl:template match="dict"> <!-- Enter Dict <br/> --> <!-- <xsl:call-template name="KeyCategory"></xsl:call-template> <xsl:call-template name="FolderStringDisplayName"></xsl:call-template> --> <li> <input type="checkbox"> <xsl:attribute name="checked">checked</xsl:attribute> </input> <i/> <!--<h2>Folder 1</h2> --> <h2> <xsl:value-of select="./string[1]"/> </h2> <p>Apps: </p> <xsl:apply-templates select="array"/> </li> </xsl:template> <xsl:template match="array"> <!-- Enter Array <br/> --> <xsl:apply-templates/> </xsl:template> <xsl:template match="string"> <!-- AppName --> <!--<p>App: <span style="color:#0000ff"><xsl:value-of select="."/></span></p> --> <p> <span> <xsl:value-of select="."/> </span> </p> </xsl:template> <!-- <xsl:template match="string"> <xsl:apply-templates select="//*[not(ancestor::dict)]"/> </xsl:template> --> <xsl:template name="KeyCategory"> <h2> <b>KC: </b> <span style="color:#ff0000"> <xsl:value-of select="./key[1]"/> </span> </h2> </xsl:template> <xsl:template name="FolderStringDisplayName"> <b>FolderName: </b> <span style="color:#ff0000"> <b> <xsl:value-of select="./string[1]"/> </b> </span> </xsl:template> </xsl:stylesheet>
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Ways to Identify & Proces, Wendell Piez wapiez@ | Thread | Re: [xsl] Re: Ways to Identify & Pr, Graydon graydon@xxxx |
Re: [xsl] Ways to Identify & Proces, Wendell Piez wapiez@ | Date | Re: [xsl] Re: Ways to Identify & Pr, Graydon graydon@xxxx |
Month |