Re: stylesheets without match="*" templates
> If such a template is used, the structure of the result sequence will be > similar to the input structure and it is sure that the outpult will be > valid XML as there is only one root node (if the input is valid xml). No there can only ever be one root node (renamed to "document node" in Xpath 2) You mean the elements which have this node as parent. XSLT stylesheets produce what XMl REC calls an external parsed entity, which basically is like an XML document but without the restriction on only having one top level element. There are various factors that effect whether one or more such elements are produced and the presence or not of <xsl:template match="*"> is only very marginally related to that. For example if you have <xsl:template match="/"> <results> <xsl:apply-templates/> </results> </xsl:template> then the result tree will only have one top level element whether or not <xsl:template match="*"><xsl:copy> occurs. conversely if you have <xsl:template match="/"> <input> <xsl:copy-of select="."/> </input> <results> <xsl:apply-templates mode="b"/> </results> </xsl:template> then the result tree will not have one top level element whether or not <xsl:template match="*"><xsl:copy> occurs. > Without going into detail, it's difficult for me to put these nodes into > the right order, because their order can't be deduced from the > templates. The usual way of converting an external parsed entity into a document, is just to wrao the whole lot in an elemnt, if you can not handle <a> <b/> </a> <c/> <d/> then treat it as if it were <div> <a> <b/> </a> <c/> <d/> </div> either by implictly doing that or by modifying the input. > My question to you is: In practise, how many stylessheets of the second > type without a template like the one above exist? lots:-) that is the identity template so it is only relevant if the input is using the same vocabulary as the output, and very often the point of transformation is to change vocabularies. But the top level structure is more directly related to the templates matching "/" than templates matching "*". David ________________________________________________________________________ The Numerical Algorithms Group Ltd is a company registered in England and Wales with company number 1249803. The registered office is: Wilkinson House, Jordan Hill Road, Oxford OX2 8DR, United Kingdom. This e-mail has been scanned for all viruses by Star. The service is powered by MessageLabs. ________________________________________________________________________
PURCHASE STYLUS STUDIO ONLINE TODAY!
Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!
Download The World's Best XML IDE!
Accelerate XML development with our award-winning XML IDE - Download a free trial today!
Subscribe in XML format