[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: DTD Subset Reduction Transformation
Mike,
To do this you want a variant of the step-by-step identity transform: <xsl:template match="node() | @*"> <xsl:copy> <xsl:apply-templates select="node() | @*"/> </xsl:copy> </xsl:template> This template works by matching any node, copying it to the result tree, and then applying-templates to any attributes or children. It will just copy your larger.xml and the result will still validate to larger.dtd. To remove the elements not in smaller.dtd, you have to know what they are. Let's say they are <bottle>, <glass> and <brush>. To the stylesheet containing the template above, you add another template like this: <xsl:template match="bottle | glass | brush"> <xsl:apply-templates/> </xsl:template> Since this template has a higher priority than the one matching node(), it gets fired in preference. Instead of copying its element node, however, it will simply descend to the next step in the tree, which you need so that any contents of <bottle>, for example, that do conform to smaller.dtd still get included. Similar means can be used to strip out unwanted attributes; also the whole thing can be parameterized if you want to maintain your list of disallowed elements outside of the template match. Note however that the unmodified technique assumes you want *all* your content, just without the unwanted element markup. The identity transform and various applications of it are described in DaveP's XSL FAQ (linked to from the page whose URL appears at the bottom of every XSL-List message ;-). This will work with any conformant processor. Good luck! Cheers, Wendell At 01:41 PM 8/30/2002, you wrote: I have an xml file that validates to a DTD. Let's call the DTD "larger.DTD". ====================================================================== Wendell Piez mailto:wapiez@xxxxxxxxxxxxxxxx Mulberry Technologies, Inc. http://www.mulberrytech.com 17 West Jefferson Street Direct Phone: 301/315-9635 Suite 207 Phone: 301/315-9631 Rockville, MD 20850 Fax: 301/315-8285 ---------------------------------------------------------------------- Mulberry Technologies: A Consultancy Specializing in SGML and XML ====================================================================== XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|
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
|