[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Combining two XBEL XML files

Subject: Re: Combining two XBEL XML files
From: Martin Honnen <Martin.Honnen@xxxxxx>
Date: Sat, 12 Jul 2008 19:10:02 +0200
Re:  Combining two XBEL XML files
Aaron Gray wrote:

Its just working with two documents at the same time, sorting them, recursing down folders in syncronism and getting back up is quite a complex task. looking for some guidance.


Here is an attempt in XSLT 2.0 but I have no files to test that with so that is completely untested. The primary input document should be one bookmark file, the URL of the second should be passed in as the parameter sec-file:


<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:my="http://example.com/2008/my" exclude-result-prefixes="my" version="2.0">

<xsl:output method="xml" indent="yes"/>

  <xsl:param name="sec-file" select="'bookmark2.xml'"/>
  <xsl:variable name="sec-doc" select="doc($sec-file)"/>

<xsl:function name="my:folder-merge" as="element()*">
<xsl:param name="folders" as="element()*"/>
<xsl:for-each-group select="$folders" group-by="title">
<xsl:sort select="current-grouping-key()"/>
<folder>
<title>
<xsl:value-of select="current-grouping-key()"/>
</title>
<xsl:sequence select="my:folder-merge(current-group()/folder)"/>
<xsl:sequence select="my:bookmark-merge(current-group()/bookmark)"/>
</folder>
</xsl:for-each-group>
</xsl:function>


  <xsl:function name="my:bookmark-merge" as="element()*">
    <xsl:param name="bookmarks" as="element()*"/>
    <xsl:for-each-group select="$bookmarks" group-by="@href">
      <xsl:sort select="current-group()[1]/title"/>
      <xsl:sequence select="current-group()[1]"/>
    </xsl:for-each-group>
  </xsl:function>

<xsl:template match="xbel">
<xsl:copy>
<xsl:sequence select="my:folder-merge(folder | $sec-doc/xbel/folder)"/>
<xsl:sequence select="my:bookmark-merge(bookmark | $sec-doc/xbel/bookmark)"/>
</xsl:copy>
</xsl:template>


</xsl:stylesheet>


--


	Martin Honnen
	http://JavaScript.FAQTs.com/

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2011 All Rights Reserved.