// Creates an xlstTransform from file specified by path. func newXsltTransform(path string) (*xsltTransform, error) { doc, err := xml.ReadFile(path, xml.StrictParseOption) if err != nil { return nil, err } stylesheet, err := xslt.ParseStylesheet(doc, path) if err != nil { doc.Free() return nil, err } result := new(xsltTransform) result.stylesheet = stylesheet return result, nil }
func main() { flag.Usage = usage flag.Parse() if flag.NArg() < 2 { usage() return } //set some prefs based on flags xslfile := flag.Arg(0) inxml := flag.Arg(1) style, err := xml.ReadFile(xslfile, xml.StrictParseOption) if err != nil { fmt.Println(err) return } doc, err := xml.ReadFile(inxml, xml.StrictParseOption) if err != nil { fmt.Println(err) return } //TODO: register some extensions (EXSLT, testing, debug) //TODO: process XInclude if enabled stylesheet, err := xslt.ParseStylesheet(style, xslfile) if err != nil { fmt.Println(err) return } options := xslt.StylesheetOptions{*indent, nil} output, err := stylesheet.Process(doc, options) if err != nil { fmt.Println(err) return } fmt.Println(output) }