[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Re: gather all similar elements in different docs
This would never happen if the type of the variable is declared as a manner of a systematic habbit: <xsl:variable name="defs" as="element()*"> <xsl:copy-of select="doc('lsb/content/glossary-1.1.1.xml')//tr"/> <xsl:copy-of select="doc('lsb/content/modules-1-glossary.xml')//tr"/> <xsl:copy-of select="doc('lsb/content/modules-2-glossary.xml')//tr"/> <xsl:copy-of select="doc('lsb/content/modules-3-glossary.xml')//tr"/> <xsl:copy-of select="doc('lsb/content/modules-4-glossary.xml')//tr"/> </xsl:variable> Even more, there is no need to copy all these nodes. One can just reference them, even in XSLT 1.0 (just omit the "as" attribute): <xsl:variable name="defs" as="element()*" select = " document('lsb/content/glossary-1.1.1.xml')//tr | document('lsb/content/modules-1-glossary.xml')//tr | document('lsb/content/modules-2-glossary.xml')//tr | document('lsb/content/modules-3-glossary.xml')//tr | document('lsb/content/modules-4-glossary.xml')//tr " /> -- Cheers, Dimitre Novatchev --------------------------------------- Truly great madness cannot be achieved without significant intelligence. --------------------------------------- To invent, you need a good imagination and a pile of junk ------------------------------------- Never fight an inanimate object ------------------------------------- You've achieved success in your field when you don't know whether what you're doing is work or play On Fri, Jan 9, 2009 at 1:49 PM, Robert Koberg <rob@xxxxxxxxxx> wrote: > ufff... nevermind. I needed to do: > > <xsl:apply-templates select="$defs/*"> > > > On Jan 9, 2009, at 4:48 PM, Robert Koberg wrote: > >> Hi, (using saxon9) >> >> I have a few pages that each contain a table of definitions. The tables >> look like (they do not have a namespace): >> >> <table border="0" cellspacing="0"> >> <tr> >> <td> >> <p>absenteeism</p> >> </td> >> <td> >> <p>frequent or habitual absence from school</p> >> </td> >> </tr> >> .... >> >> Can I gather up all of the TR elements, like my defs variable below (or >> some other way) and apply-templates on them (while sorting)? The stylesheet >> below causes an error "Too many nested apply-templates calls. The stylesheet >> may be looping." at the <xsl:apply-templates select="$defs"> >> >> What am I doing wrong here? >> >> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" >> version="2.0"> >> >> <xsl:variable name="defs"> >> <xsl:copy-of select="doc('lsb/content/glossary-1.1.1.xml')//tr"/> >> <xsl:copy-of select="doc('lsb/content/modules-1-glossary.xml')//tr"/> >> <xsl:copy-of select="doc('lsb/content/modules-2-glossary.xml')//tr"/> >> <xsl:copy-of select="doc('lsb/content/modules-3-glossary.xml')//tr"/> >> <xsl:copy-of select="doc('lsb/content/modules-4-glossary.xml')//tr"/> >> </xsl:variable> >> >> <xsl:template match="/"> >> <glossentries> >> <xsl:apply-templates select="$defs"> >> <xsl:sort select="normalize-space(td[1]/p/text())"/> >> </xsl:apply-templates> >> </glossentries> >> </xsl:template> >> >> <xsl:template match="tr"> >> <xsl:variable name="term" select="normalize-space(td[1]/p/text())"/> >> <xsl:variable name="file-name" select="translate($term, ' ', '-')"/> >> <glossentry file-name="{$file-name}"> >> <term> >> <xsl:value-of select="$term"/> >> </term> >> <definition> >> <xsl:copy-of select="td[2]/*"/> >> </definition> >> </glossentry> >> </xsl:template> >> >> </xsl:stylesheet> >> >> thanks, >> -Rob
|
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
|