没有XML文件中包含的DTD声明的XML文件的Java DTD验证?(Java DTD validation of XML files without the DTD declaration included in the XML File?)
如何使用外部DTD文件来验证我的XML文件?
DTD将位于某些URL上,例如http://localhost/example.dtd
并且XML文件中没有引用DTD,因此我需要在Java servlet中执行此操作。
我正在使用JDOM来处理当前的XML文件。
任何帮助或指示表示赞赏
How can I use an external DTD file to validate my XML file against?
The DTD will be located on some url e.g. http://localhost/example.dtd
and the DTD is not referenced in the XML file, so I need to do this in my Java servlet.
I am using JDOM for my current processing of XML files.
Any help or pointers is appreciated
原文:https://stackoverflow.com/questions/4749062
最满意答案
从URL获取并将正文转换为Go
string
类型时没有错误。 例如,package main import ( "fmt" "io/ioutil" "log" "net/http" ) func main() { url := "http://www.indiegogo.com/projects/culcharge-smallest-usb-charge-and-data-cable-for-iphone-and-android" res, err := http.Get(url) if err != nil { log.Fatal(err) } body, err := ioutil.ReadAll(res.Body) res.Body.Close() if err != nil { log.Fatal(err) } text := string(body) fmt.Println(len(body), len(text)) }
输出:
66363 66363
您没有向我们提供一小段代码,它们以您描述的方式编译,运行和失败。 这让我们都在猜测。
There is no error when getting from the url and converting the body to the Go
string
type. For example,package main import ( "fmt" "io/ioutil" "log" "net/http" ) func main() { url := "http://www.indiegogo.com/projects/culcharge-smallest-usb-charge-and-data-cable-for-iphone-and-android" res, err := http.Get(url) if err != nil { log.Fatal(err) } body, err := ioutil.ReadAll(res.Body) res.Body.Close() if err != nil { log.Fatal(err) } text := string(body) fmt.Println(len(body), len(text)) }
Output:
66363 66363
You didn't provide us with a small fragment of code which compiles, runs, and fails in the manner you describe. That leaves us all guessing.
相关问答
更多-
显然在Go 1.3 http.Client有超时字段 timeout := time.Duration(5 * time.Second) client := http.Client{ Timeout: timeout, } client.Get(url) 这对我来说是个窍门。 Apparently in Go 1.3 http.Client has Timeout field timeout := time.Duration(5 * time.Second) client := http.Clie ...
-
从URL获取并将正文转换为Go string类型时没有错误。 例如, package main import ( "fmt" "io/ioutil" "log" "net/http" ) func main() { url := "http://www.indiegogo.com/projects/culcharge-smallest-usb-charge-and-data-cable-for-iphone-and-android" res, err := ...
-
我没有办法绕过这个但是如果你真的必须使用小写标题名称,那么你可以通过使用小写密钥创建自己的http.Header来解决这个问题。 示例( 正在播放 ): import "fmt" import "strings" import "net/http" // ... req, _ := http.NewRequest("GET", "http://foo", nil) req.Header.Add("myheader", "myheadervalue") lowerCaseHeader := make( ...
-
我相信这是来自你的 if (xhttp.readyState == 4 && xhttp.status == 200) { document.getElementById("loginerrormessageid").innerHTML = xhttp.responseText; } 当重定向返回时,您将获得整个页面,并且只是将其加载到错误消息中,因为没有条件。 你可能想要做一些事情 if (isAuthenticated) { location.href = "/"; // whatev ...
-
终止HTTP请求的服务只不过是从ServeHTTP()方法返回,例如: http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { // examine incoming params if !ok { str := `{"Result":"","Error":"No valide Var"}` fmt.Fprint(w, str) return } ...
-
curl命令将API密钥传递给URL查询字符串中的服务器。 以下是Go中如何做同样的事情: payload := url.Values{} payload.Add("api_key", "myapikey") req, err := http.NewRequest("GET", "https://someendpoint?" + payload.Encode(), nil) The curl command passes the API key to the server in the URL query ...
-
不确定这是正确的设计,但我怀疑问题是,你开始第二个例行程序,第一个例程继续并完成连接等的写入。 要停止此操作,您可以使用等待组( http://golang.org/pkg/sync/#WaitGroup )使第一个例程等待。 这就停止了为什么你试图把它放到一个线程中的全部推理(因此我认为你有一个设计问题)。 这是一些未经测试的代码应该起作用或至少有助于正确的方向。 package main import ( "encoding/json" "net/http" "sync" ...
-
网址分析错误 太多的重定向时间 tcp connect \ write \ read timeout 302状态,但为null位置标头 等等 您可以阅读http包中的源代码。 然后你可以找到这个函数http.Get返回的所有错误。 URL parse error too much redirect times tcp connect\write\read timeout 302 status, but null Location header and so on You can read the sourc ...
-
您的浏览器正在寻找favicon.ico发起两个请求。 尝试卷曲,你会得到一个请求。 Your browser is looking for a favicon.ico initiating two requests. Try with curl and you will get one request.
-
r.URL字段通过解析HTTP请求URI来创建。 r.Host字段是主机请求标头的值。 这与调用r.Header.Get("Host")值相同。 如果线路上的HTTP请求是: GET /pub/WWW/TheProject.html HTTP/1.1 Host: www.example.org:8080 然后r.URL.Host是“”而r.Host是www.example.org:8080 。 r.URL.Host和r.Host的价值几乎总是不同的。 在代理服务器上, r.URL.Host是目标服务器 ...