Altova Mailing List Archives>Archive Index >microsoft.public.xsl Archive Home >Recent entries >Thread Prev - Re: Question on flow >Thread Next - Re: Question on flow Re: Question on flowTo: NULL Date: 4/2/2008 8:45:00 AM Martin Honnen wrote: > tshad wrote: > >> 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. > > No, processing does not start at the first template. Processing starts > at the root node (document node) of your primary XML input document, > see <URL:http://www.w3.org/TR/xslt#section-Processing-Model>. Then > the best matching template is used and its content determines which > nodes are processed next. And there is a built-in template > (<URL:http://www.w3.org/TR/xslt#built-in-rule>) > <xsl:template match="*|/"> > <xsl:apply-templates/> > </xsl:template> > which makes sure the child nodes of the root node are processed. > So in your sample XML input the above built-in template is the first > template to be applied, then the child nodes of the root node > (document node) are processed which is the 'REPORT' element. As you > have a matching template for 'REPORT' elements that template is > applied. And the xsl:apply-templates in that template determine which > nodes are processed next, and pattern matching determines which > templates are applied to these nodes. If it decides which one to choose, why if you have the pattern: <xsl:template match="FIELDS/*[starts-with(name(), 'SCMCOMMENTS')]"> does it know to use this one: <xsl:apply-templates select="FORMS/FORM/FIELDS/*[starts-with(name(), 'SCMCOMMENTS')]"/> They aren't the same - but they are similar. Why did you leave FORMS/FORM/ off of the template but not the apply-template? In my template, I now have: <xsl:apply-templates select="FORMS/FORM/FIELDS/*[not(starts-with(name(), 'SCMCOMMENTS')) and not(starts-with(name(), 'GEN_COMMENTS')) and not(starts-with(name(), 'CMTCONDITION')) and not(starts-with(name(), 'CSTCOMMENTS')) and not(starts-with(name(), 'SITE_OPINION')) and not(starts-with(name(), 'CMPHIST_TXT')) and not(starts-with(name(), 'GSU') and ../../@FORMCODE = '(AC)') and not(name() = 'OTHERFILENUMBER' and ../../@FORMCODE = '(AC)') and not(name() = 'FNMA_FILENUMBER' and ../../@FORMCODE = '(AC)')]"/> and the template is: <xsl:template match="FIELDS/*[not(starts-with(name(), 'SCMCOMMENTS')) and not(starts-with(name(), 'GEN_COMMENTS')) and not(starts-with(name(), 'CMTCONDITION')) and not(starts-with(name(), 'CSTCOMMENTS')) and not(starts-with(name(), 'SITE_OPINION')) and not(starts-with(name(), 'CMPHIST_TXT')) and not(starts-with(name(), 'GSU') and ../../@FORMCODE = '(AC)') and not(name() = 'OTHERFILENUMBER' and ../../@FORMCODE = '(AC)') and not(name() = 'FNMA_FILENUMBER' and ../../@FORMCODE = '(AC)')]"> does it have to match exactly (except for the FORMS/FORM/)? Thanks, Tom | ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
