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/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 | ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
