[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: combining 2 different XML files within the same XS
Hi Todd, > I would have thought that the below code you supplied would have > sorted ALL the nodes in $mergedset by date, not have done it > separately > > <xsl:apply-templates select="//date"> > <!-- since your criterion is your date, we'll go straight to them --> > <xsl:sort type="number"/> > <!-- let's sort em while we're at it --> > </xsl:apply-templates> > > why is this sort not encompassing both sets of nodes? is there a way > to make it sort both set's of nodes? The path "//date" says "from the root node *of the current document*, gather together all the date elements and apply templates to them in sorted order". You don't want to just sort the date elements of the current document -- you want to sort all of the event and game elements from both documents. The $mergedset variable holds the root nodes of the two documents. (When you could how many nodes the $mergedset variable holds, you get 2 because there are two files -- two root nodes.) To get all the event and game elements from both documents, you can use: $mergedset/events/event | $mergedset/games/game You can then apply templates to these nodes, sorted in date order, as follows: <xsl:apply-templates select="$mergedset/events/event | $mergedset/games/game"> <xsl:sort select="date" type="number" /> </xsl:apply-templates> and have a template that turns both event and game elements into app elements: <xsl:template match="event | game"> <app type="{local-name()}"> <xsl:copy-of select="@*" /> <xsl:copy-of select="*" /> </app> </xsl:template> If you want to filter the events/games, I suggest that you do so when you created the set of events and games, for example use: ($mergedset/events/event | $mergedset/games/game) [date > 20020814 and 20020821 > date] to get those events and games dated between 20020814 and 20020821 exclusive. Cheers, Jeni --- Jeni Tennison http://www.jenitennison.com/ 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
|