initial parsing of zotero's rdf with etree

This commit is contained in:
Marcell Mars 2022-03-23 23:48:42 +01:00
parent 9c7f016f7d
commit b668476c47
2 changed files with 11 additions and 9 deletions

View File

@ -2,7 +2,7 @@ package cmd
import (
"fmt"
"strings"
"os"
"accorder/pkg/calibre"
@ -61,13 +61,16 @@ should be enough for the next successful build).`,
panic(err)
}
root := doc.SelectElement("rdf:RDF")
for _, bib := range root.FindElements("//*") {
if bib.Space == "bib" {
if strings.ToLower(bib.Tag) == "book" {
fmt.Println(bib.Tag)
fmt.Printf("%#v\n\n", bib)
}
}
for _, z := range root.FindElements("[link:type]") {
doc := etree.NewDocument()
doc.SetRoot(z.Copy())
fmt.Println("~ ~ ~ ~")
fmt.Println(doc.WriteTo(os.Stdout))
elm := root.FindElement(fmt.Sprintf("[@rdf:resource='%s']", z.SelectAttr("rdf:about").Value))
doc.SetRoot(elm.Parent().Copy())
fmt.Println("+++++")
fmt.Println(doc.WriteTo(os.Stdout))
fmt.Println("~ ~ ~ ~")
}
calibre.RenderStandaloneApp(calibrePath, librarianName, libraryUUID, librarySecret, jsonPath)
},

View File

@ -3,7 +3,6 @@ package cmd
import (
"encoding/json"
"fmt"
"log"
"os"
"path/filepath"