Recently I've wanted to start adding more cards to my Supermemo CE collection. Much to my shock and disgust the only way to do it is to export XML, merge the two XML's externally, and then reimport. It's completely impractical when your collection is 3,000 plus elements and you just want to add ~50 new cards at a time. (This was MUCH easier on Palm Supermemo 5 years ago.)
This is the XSLT code (merge.xslt) that should do the trick for merging:
<xsl:transform version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml"
encoding="UTF-8"
indent="no" />
<xsl:template match="/">
<SuperMemoCollection>
<xsl:copy-of select="//SuperMemoCollection/SuperMemoElement"/>
<xsl:copy-of select="document('file_to_append.xml')//SuperMemoCollection/SuperMemoElement"/>
</SuperMemoCollection>
</xsl:template>
</xsl:transform>
Then get some XML processing thinggy like nxslt (freeware) and just do:
nxslt.exe exported.xml merge.xslt -ascii -o reimportme.xml
The beautiful thing here is that your file_to_append.xml does NOT need to be Decimal NCR encoded. I am using a UTF-16 LE file with Japanese text right in there and merging it with the UTF-8 file that Supermemo CE exports, and nxslt converts the final output to the Supermemo CE required UTF-8 with Decimal NCR encoded Japanese automatically since I used the "-ascii" flag.
If you want to make it even easier you can use my Powershell script. Copy the contents of the zip to your SD card and then future additions to your collection will go this smooth:
- Export collection in Supermemo CE
- Plug you SD card into your desktop
- Copy over new_stuff_to_add.xml to the SD card
- Type: .\combineSMCExml.ps1 exported.xml new_stuff_to_add.xml
- Import collection (exported.xml) back into Supermemo CE
The zip file containing merge.xslt, nxslt.exe, and combineSMCExml.ps1 can be downloaded here: combinesmcexml.zip.
WARNING:
I encountered a very frustrating problem with nxslt -- if there are *any* encoded HTML tags in new_stuff_to_add.xml (of the type < or >) then instead of getting the Decimal NCR encoded you need for Japanese/Chinese to show up in SMCE you will get a string of ???? question marks. If anyone knows a workaround, please let me know. 8/18: It seems upgrading to nxslt2 does the trick, the only problem is the '-ascii' tag disappears.

