Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: Question on flow

From: msb <msbalaji@-----.--->
To: NULL
Date: 4/2/2008 4:03:00 AM
On Apr 2, 12:59=A0am, "tshad" <ts...@dslextreme.com> wrote:
> 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. =A0Based on how mine wor=
ks 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. =A0If I don't call any=

> other function, from a startup function then only the startup function get=
s
> executed even if there there are other functions in my program (discountin=
g
> events, of course).
>
> In XSLT, it seems that the 1st template is like your startup routine. =A0I=
f
> 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. =A0If 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. =A0As it works exactly the =
same
> if I change it to <REPORTING>. =A0In the copy case, it will put whatever m=
y
> root element is as my new root element and the other case will put
> <REPORTING> as my root element. =A0Other 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. =A0But if I have "/" and
> <xsl:copy>, I don't get a root tag. =A0If I do "/" and "<REPORTING> (in pl=
ace
> of the <xsl:copy>), it works fine with <REPORTING> as my root tag.
>
> ************************************************
> <xsl:stylesheet
> =A0 =A0 xmlns:xsl=3D"http://www.w3.org/1999/XSL/Transform"
> =A0 =A0 version=3D"1.0">
>
> =A0<xsl:output method=3D"xml" indent=3D"yes"/>
>
> =A0<xsl:template match=3D"REPORT">
> =A0 <xsl:copy>
> =A0 =A0<xsl:apply-templates
> =A0 select=3D"FORMS/FORM/FIELDS/*[not(starts-with(name(), 'SCMCOMMENTS')) =
and
> not(starts-with(name(), 'GEN_COMMENTS')) and not(starts-with(name(),
> 'CMPHIST_TXT'))]"/>
> =A0 =A0<form>
> =A0 =A0 <sectionNumber>0</sectionNumber>
> =A0 =A0 <primary>True</primary>
> =A0 =A0 <formName>
> =A0 =A0 =A0<xsl:value-of select=3D"FORMS/FORM/@FORMCODE"/>
> =A0 =A0 </formName>
> =A0 =A0 <tagName>SCMCOMMENTS_1</tagName>
> =A0 =A0 <flags>0</flags>
> =A0 =A0 <format>0</format>
> =A0 =A0 <value>
> =A0 =A0 =A0<xsl:apply-templates select=3D"FORMS/FORM/FIELDS/*[starts-with(=
name(),
> 'SCMCOMMENTS')]"/>
> =A0 =A0 </value>
> =A0 =A0</form>
> =A0 =A0<form>
> =A0 =A0 <sectionNumber>0</sectionNumber>
> =A0 =A0 <primary>True</primary>
> =A0 =A0 <formName>
> =A0 =A0 =A0<xsl:value-of select=3D"FORMS/FORM/@FORMCODE"/>
> =A0 =A0 </formName>
> =A0 =A0 <tagName>GEN_COMMENTS_1</tagName>
> =A0 =A0 <flags>0</flags>
> =A0 =A0 <format>0</format>
> =A0 =A0 <value>
> =A0 =A0 =A0<xsl:apply-templates select=3D"FORMS/FORM/FIELDS/*[starts-with(=
name(),
> 'GEN_COMMENTS')]"/>
> =A0 =A0 </value>
> =A0 =A0</form>
> =A0 =A0<form>
> =A0 =A0 <sectionNumber>0</sectionNumber>
> =A0 =A0 <primary>True</primary>
> =A0 =A0 <formName>
> =A0 =A0 =A0<xsl:value-of select=3D"FORMS/FORM/@FORMCODE"/>
> =A0 =A0 </formName>
> =A0 =A0 <tagName>CMPHIST_TXT</tagName>
> =A0 =A0 <flags>0</flags>
> =A0 =A0 <format>0</format>
> =A0 =A0 <value>
> =A0 =A0 =A0<xsl:apply-templates select=3D"FORMS/FORM/FIELDS/*[starts-with(=
name(),
> 'CMPHIST_TXT')]"/>
> =A0 =A0 </value>
> =A0 =A0</form>
> =A0 =A0<form>
> =A0 =A0 <sectionNumber>
> =A0 =A0 =A0<xsl:value-of select=3D"FORMS/FORM/@SECCODE"/>
> =A0 =A0 </sectionNumber>
> =A0 =A0 <primary>True</primary>
> =A0 =A0 <formName>
> =A0 =A0 =A0<xsl:value-of select=3D"FORMS/FORM/@FORMCODE"/>
> =A0 =A0 </formName>
> =A0 =A0 <tagName>FormFormats</tagName>
> =A0 =A0 <flags>0</flags>
> =A0 =A0 <format>0</format>
> =A0 =A0 <value>
> =A0 =A0 =A0<xsl:apply-templates select=3D"FORMS/FORM/@*"/>
> =A0 =A0 </value>
> =A0 =A0</form>
> =A0 =A0<xsl:apply-templates select=3D"FORMS/FORM/attachments/attachment"/>=

> =A0 </xsl:copy>
> =A0</xsl:template>
>
> =A0<xsl:template match=3D"FIELDS/*[not(starts-with(name(), 'SCMCOMMENTS'))=
 and
> not(starts-with(name(), 'GEN_COMMENTS')) and not(starts-with(name(),
> 'CMPHIST_TXT'))]">
> =A0 <form>
> =A0 =A0<sectionNumber>
> =A0 =A0 <xsl:text>0</xsl:text>
> =A0 =A0</sectionNumber>
> =A0 =A0<primary>True</primary>
> =A0 =A0<formName>
> =A0 =A0 <xsl:value-of select=3D"../../@FORMCODE"/>
> =A0 =A0</formName>
> =A0 =A0<tagName>
> =A0 =A0 <xsl:value-of select=3D"name()"/>
> =A0 =A0</tagName>
> =A0 =A0<flags>0</flags>
> =A0 =A0<format>0</format>
> =A0 =A0<value>
> =A0 =A0 <xsl:value-of select=3D"."/>
> =A0 =A0</value>
> =A0 </form>
> =A0</xsl:template>
>
> =A0<xsl:template match=3D"FIELDS/*[starts-with(name(), 'SCMCOMMENTS')]">
> =A0 <xsl:value-of select=3D"."/>
> =A0 <xsl:if test=3D"position() !=3D last()">
> =A0 =A0<xsl:text> </xsl:text>
> =A0 </xsl:if>
> =A0</xsl:template>
> =A0<xsl:template match=3D"FIELDS/*[starts-with(name(), 'GEN_COMMENTS')]">
> =A0 <xsl:value-of select=3D"."/>
> =A0 <xsl:if test=3D"position() !=3D last()">
> =A0 =A0<xsl:text> </xsl:text>
> =A0 </xsl:if>
> =A0</xsl:template>
> =A0<xsl:template match=3D"FIELDS/*[starts-with(name(), 'CMPHIST_TXT')]">
> =A0 <xsl:value-of select=3D"."/>
> =A0 <xsl:if test=3D"position() !=3D last()">
> =A0 =A0<xsl:text> </xsl:text>
> =A0 </xsl:if>
> =A0</xsl:template>
>
> =A0<xsl:template match=3D"FORM/@*">
> =A0 <xsl:value-of select=3D"concat(name(), '=3D', .)"/>
> =A0 <xsl:if test=3D"position() !=3D last()">
> =A0 =A0<xsl:text> </xsl:text>
> =A0 </xsl:if>
> =A0</xsl:template>
>
> </xsl:stylesheet>
> ************************************************
>
> Am I close?
>
> Thanks,
>
> Tom

Hi,

 Lot of peopls they misunderstood here. '/' mention doucment element
not root element.

 your using

<xsl:template match=3D"/">
<xsl:apply-templates/>
</xsl:template>

 it shows document element inside content to be pushed to other
templates.

 And put your XML input file.

Regards,
Balaji. M


transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent