Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: Question on flow

From: "tshad" <tfs@----------.--->
To: NULL
Date: 4/3/2008 12:21:00 AM

Martin Honnen wrote:
> tshad wrote:
>
>> But then what is happening 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. It seems the "/" drops the root node (with 
>> copy) and "/*" (with
>> copy) uses the existing root node.
>>
>> I assume the reason "/" and <REPORT> work is because "/" is dropping
>> the root (document) node but I am supplying my own.
>>
>> <xsl:template match="/">
>>   <xsl:copy>
>>
>> doesn't work (missing root node)
>
> The root node in the XSLT/XPath model is the document node, it is
> different from the root element.
> So
>   <xsl:template match="/">
> matches the root node and you can copy that if you want but it is
> different from
>   <xsl:template match="/*">
> which matches the root element.

OK, so if I have an xml file:
*********************************************************
<?xml version="1.0" encoding="utf-8"?>
<REPORT VERSION="1.10" FILENUM="" DESCRIPTION="Form Utility XML: 3/18/2008
12:27:13 PM" MAJORFORM="1004">
 <FORMS>
  <FORM NUM="1" FORMCODE="1004" SECCODE="1" DESC="" MAJOR="True" >
   <FIELDS>
    <OTHERFILENUMBER>692</OTHERFILENUMBER>
    <FNMA_FILENUMBER>693</FNMA_FILENUMBER>
    <SUBPROPADDRESS>3</SUBPROPADDRESS>
    <SCMCOMMENTS_1>This is a test line 1</SCMCOMMENTS_1>
    <SCMCOMMENTS_2>This is a test line 2</SCMCOMMENTS_2>
    <SCMCOMMENTS_3>This is a test line 3</SCMCOMMENTS_3>
    <SCMCOMMENTS_4>This is a test line 4</SCMCOMMENTS_4>
   </FIELDS>
  </FORM>
 </FORMS>
</REPORT>
*********************************************************

and I do (if I read you correctly):
<xsl:template match="/*">
<xsl:copy>

I am copying copying the root Element, which in this case I assume is 
<Report>.  So I will copy everything from <REPORT> to </REPORT>

And will have as my root - <Report> in my transformation.

If I do:
<xsl:template match="/">
<xsl:copy>

I am copying the whole document from <?xml...> to </REPORT>

But I won't have a root (and I get an error).  For some reason, it doesn't 
use the <REPORT> node in my transformation as the "/*" does.

If I do "/" and "<REPORTING> (in place
of the <xsl:copy>), it works fine with <REPORTING> as my root tag.

Why does it do the copy?  Does this have to do with the built-in templates 
you mentioned?

Thanks,

Tom




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