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 ( import (
"fmt" "fmt"
"strings" "os"
"accorder/pkg/calibre" "accorder/pkg/calibre"
@ -61,13 +61,16 @@ should be enough for the next successful build).`,
panic(err) panic(err)
} }
root := doc.SelectElement("rdf:RDF") root := doc.SelectElement("rdf:RDF")
for _, bib := range root.FindElements("//*") { for _, z := range root.FindElements("[link:type]") {
if bib.Space == "bib" { doc := etree.NewDocument()
if strings.ToLower(bib.Tag) == "book" { doc.SetRoot(z.Copy())
fmt.Println(bib.Tag) fmt.Println("~ ~ ~ ~")
fmt.Printf("%#v\n\n", bib) 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) calibre.RenderStandaloneApp(calibrePath, librarianName, libraryUUID, librarySecret, jsonPath)
}, },

View File

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