1 Star 0 Fork 0

jack/libxml2

加入 Gitee
与超过 1400万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
option.go 1.08 KB
一键复制 编辑 原始数据 按行查看 历史
Daisuke Maki 提交于 2020-09-15 11:55 +08:00 . First pass at solving #67
package xsd
import (
"net/url"
"os"
"path/filepath"
"github.com/lestrrat-go/libxml2/internal/option"
)
// WithPath provides a hint to the XSD parser as to where the
// document being parsed is located at.
//
// This is useful when you must resolve relative paths inside a
// document, because to use relative paths the parser needs to
// know the reference location (i.e. location of the document
// being parsed). In case where you are parsing using `ParseFromFile()`
// this is handled automatically by the `ParseFromFile` method,
// but if you are using `Parse` method this is required
//
// If the path is provided as a relative path, the current directory
// should be obtainable via `os.Getwd` when this call is made, otherwise
// path resolution may fail in weird ways.
func WithPath(path string) Option {
if !filepath.IsAbs(path) {
if curdir, err := os.Getwd(); err == nil {
path = filepath.Join(curdir, path)
}
}
return WithURI(
(&url.URL{
Scheme: `file`,
Path: path,
}).String(),
)
}
func WithURI(v string) Option {
return option.New(option.OptKeyWithURI, v)
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/wholesky/libxml2.git
git@gitee.com:wholesky/libxml2.git
wholesky
libxml2
libxml2
e6d9de61b80d

搜索帮助