Altova Mailing List Archives>Archive Index >microsoft.public.xsl Archive Home >Recent entries [Thread Prev] >Thread Next - Re: Question on flow Question on flowTo: NULL Date: 4/1/2008 12:59:00 PM I have been working on my XSLT page and have a couple questions on flow. In my example XSLT file, I have have 4 Templates. Based on how mine works I think I understand how the flow works but am not sure. It seems that only the 1st template is the driving template, similar to Main() in C or the startup function in any program. If I don't call any other function, from a startup function then only the startup function gets executed even if there there are other functions in my program (discounting events, of course). In XSLT, it seems that the 1st template is like your startup routine. If you don't do an <xsl:apply-templates> or <xsl:call-template> only this 1st template will get run and it will execute all the commands in it until it hits the </xsl:template> tag. All the other templates get executed only if they are applied or called. This seems to be what happens. If I take all the apply-templates out of my 1st template, none of the other templates get executed and all the 1st template does. I am a little confused on the necessity of using the <xsl:copy> (except to soft code the root element), as in my example. As it works exactly the same if I change it to <REPORTING>. In the copy case, it will put whatever my root element is as my new root element and the other case will put <REPORTING> as my root element. Other than that, there doesn't seem to be any difference. I also am a little confused as to the use of "/*" vs "/" vs "REPORT" in my first template line. Both "/*" and "REPORT" give me the same results. But if I have "/" and <xsl:copy>, I don't get a root tag. If I do "/" and "<REPORTING> (in place of the <xsl:copy>), it works fine with <REPORTING> as my root tag. ************************************************ <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:output method="xml" indent="yes"/> <xsl:template match="REPORT"> <xsl:copy> <xsl:apply-templates select="FORMS/FORM/FIELDS/*[not(starts-with(name(), 'SCMCOMMENTS')) and not(starts-with(name(), 'GEN_COMMENTS')) and not(starts-with(name(), 'CMPHIST_TXT'))]"/> <form> <sectionNumber>0</sectionNumber> <primary>True</primary> <formName> <xsl:value-of select="FORMS/FORM/@FORMCODE"/> </formName> <tagName>SCMCOMMENTS_1</tagName> <flags>0</flags> <format>0</format> <value> <xsl:apply-templates select="FORMS/FORM/FIELDS/*[starts-with(name(), 'SCMCOMMENTS')]"/> </value> </form> <form> <sectionNumber>0</sectionNumber> <primary>True</primary> <formName> <xsl:value-of select="FORMS/FORM/@FORMCODE"/> </formName> <tagName>GEN_COMMENTS_1</tagName> <flags>0</flags> <format>0</format> <value> <xsl:apply-templates select="FORMS/FORM/FIELDS/*[starts-with(name(), 'GEN_COMMENTS')]"/> </value> </form> <form> <sectionNumber>0</sectionNumber> <primary>True</primary> <formName> <xsl:value-of select="FORMS/FORM/@FORMCODE"/> </formName> <tagName>CMPHIST_TXT</tagName> <flags>0</flags> <format>0</format> <value> <xsl:apply-templates select="FORMS/FORM/FIELDS/*[starts-with(name(), 'CMPHIST_TXT')]"/> </value> </form> <form> <sectionNumber> <xsl:value-of select="FORMS/FORM/@SECCODE"/> </sectionNumber> <primary>True</primary> <formName> <xsl:value-of select="FORMS/FORM/@FORMCODE"/> </formName> <tagName>FormFormats</tagName> <flags>0</flags> <format>0</format> <value> <xsl:apply-templates select="FORMS/FORM/@*"/> </value> </form> <xsl:apply-templates select="FORMS/FORM/attachments/attachment"/> </xsl:copy> </xsl:template> <xsl:template match="FIELDS/*[not(starts-with(name(), 'SCMCOMMENTS')) and not(starts-with(name(), 'GEN_COMMENTS')) and not(starts-with(name(), 'CMPHIST_TXT'))]"> <form> <sectionNumber> <xsl:text>0</xsl:text> </sectionNumber> <primary>True</primary> <formName> <xsl:value-of select="../../@FORMCODE"/> </formName> <tagName> <xsl:value-of select="name()"/> </tagName> <flags>0</flags> <format>0</format> <value> <xsl:value-of select="."/> </value> </form> </xsl:template> <xsl:template match="FIELDS/*[starts-with(name(), 'SCMCOMMENTS')]"> <xsl:value-of select="."/> <xsl:if test="position() != last()"> <xsl:text> </xsl:text> </xsl:if> </xsl:template> <xsl:template match="FIELDS/*[starts-with(name(), 'GEN_COMMENTS')]"> <xsl:value-of select="."/> <xsl:if test="position() != last()"> <xsl:text> </xsl:text> </xsl:if> </xsl:template> <xsl:template match="FIELDS/*[starts-with(name(), 'CMPHIST_TXT')]"> <xsl:value-of select="."/> <xsl:if test="position() != last()"> <xsl:text> </xsl:text> </xsl:if> </xsl:template> <xsl:template match="FORM/@*"> <xsl:value-of select="concat(name(), '=', .)"/> <xsl:if test="position() != last()"> <xsl:text> </xsl:text> </xsl:if> </xsl:template> </xsl:stylesheet> ************************************************ Am I close? Thanks, Tom | ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
