How to validate XHTML with Xerces on commandline when w3.org stopped serving some files? - xhtml

I copied the example XHTML file from the W3C recommendation:
$ cat > sample.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html version="-//W3C//DTD XHTML 1.1//EN"
xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.w3.org/1999/xhtml
http://www.w3.org/MarkUp/SCHEMA/xhtml11.xsd"
>
<head>
<title>Virtual Library</title>
</head>
<body>
<p>Moved to example.org.</p>
</body>
</html>
The commandline tool sax.Counter does not work for the sample:
$ java -classpath /usr/share/java/xercesImpl-2.11.0.jar:/usr/share/java/xercesSamples.jar sax.Counter -v -n -np -s -f sample.xml
error: Parse error occurred - http://www.w3.org/TR/xhtml11/DTD/xhtml-datatypes-1.mod
java.io.FileNotFoundException: http://www.w3.org/TR/xhtml11/DTD/xhtml-datatypes-1.mod
because one of the included file is missing:
$ wget http://www.w3.org/TR/xhtml11/DTD/xhtml-datatypes-1.mod
--2018-10-22 23:08:30-- http://www.w3.org/TR/xhtml11/DTD/xhtml-datatypes-1.mod
404 Not Found
2018-10-22 23:08:45 ERROR 404: Not Found.

Delete the following two lines in the sample
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
and Xerces will work. Using Java 11 and libxerces 2.11.0:
$ export CLASSPATH=/usr/share/java/xercesImpl.jar:/usr/share/java/xercesSamples.jar
$ java sax.Counter -v -n -np -s -f sample.xml
sample.xml: 25176 ms (6 elems, 10 attrs, 0 spaces, 59 chars)
I am confused as of why the main dtd file is available but the component mod files are not. But at least w3 has kept the components of the xsd file online - until maybe one day they ditch it for some newer method to validate XML.

I quit on Xerces and use xmllint instead.
xmllint works for the said sample.xml. First, you need to manually download all schema files and save them in the same place you keep sample.xml.
Then use the main xsd file for validation:
$ xmllint --schema xhtml11.xsd sample.xml --noout
sample.xml validates
xmllint took 32 seconds to validate the sample.xml
Tested with the xmllint shipped with libxml 2.9.4 on Ubuntu as well as on the default xmllint on OS X Capitan.

Related

Use RSS from Bitrix

I'd like to use rss channel from website https://www.staraya-moneta.ru/forum/. For example https://www.staraya-moneta.ru/forum/rss/default/forum/67/.
All works fine. But sometimes I download html-file instead of rss-file.
Can you help me, please, to solve the problem?
Screenshot of html-page
For example, I try to download rss by the following cmd:
curl -XGET -H "Accept: */*" https://www.staraya-moneta.ru/forum/rss/rss2/forum/57/
I see the result:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
I try to download from browser from "Private session"
Result the same
I update page and I get the correct result - rss file
I try to add PHPSESSID and BX_USER_ID to download, but it works only sometimes.

turbo drive works for a form but not a link

I an experimenting with turbo drive without rails.
It seems to work for forms but not links.. even when the form is set to GET.
To try to keep it minimal, I have used bash and cgi, but I saw the same thing using another web framework.
$ mkdir example
$ cd example
$ cat > index.html
<meta http-equiv="Refresh" content="0; url='/cgi-bin/index.sh'" />
$ mkdir cgi-bin
$ cat > cgi-bin/index.sh
#! /usr/bin/env bash
set -e
echo Content-Type: text/html
echo
sed "s/NEW/$RANDOM/g" << EOF
<html>
<head>
<title>DEMO</title>
<script src="/node_modules/#hotwired/turbo/dist/turbo.es2017-umd.js"></script>
</head>
<body>
<h1>DEMO</h1>
<h2>$QUERY_STRING</h2>
NEW
<form action="?">
<input type="hidden" name="val" value="NEW" />
<input type="submit" />
</form>
</body>
</html>
EOF
$ chmod +x cgi-bin/index.sh
$ npm install --save #hotwired/turbo#7.0.1
$ python3 -m http.server --cgi # or whichever server
then when I go to http://localhost:8000 I get this:
Both the both the link and the submit button load the random number displayed in the link, and prepare a new random number for loading.
The difference is that the link reloads the whole page as if turbo were not included, and the form fetches.
What do I have to do to make it ajax the link as well? Did I overlook an attribute I need in the link or something?
Stepping through the code I discovered this condition:
function isHTML(url) {
return !!getExtension(url).match(/^(?:|\.(?:htm|html|xhtml))$/);
}
So I renamed index.sh to index.html and it worked! I guess it probably works with no filename as well.
That restrictions only applies to links, not forms.

Saxon XQuery catalog files to override DTD URI?

I am trying to use a catalog file to override DTD location in XML files. I tried following all of the tips here How to use saxon built-in catalog feature but have been unable to get it to work. I reduced to this simple example:
Confirmed version of Saxon:
C:\test>java net.sf.saxon.Query
No query file name
Saxon-HE 9.7.0.7J from Saxonica
...
My catalog file. I tried to reduce to simplest (uriSuffix):
<catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog">
<uriSuffix uriSuffix="bad.dtd" uri="good.dtd" />
</catalog>
Confirmed resolver is in classpath and behaving as expected with catalog:
C:\test>java org.apache.xml.resolver.apps.resolver -c didcat.xml -u bad.dtd uri
Cannot find CatalogManager.properties
Resolve URI (uri):
uri: bad.dtd
Result: file:/C:/test/good.dtd
Simple test.xml file:
<?xml version="1.0"?>
<!DOCTYPE a SYSTEM "bad.dtd">
<a>hello world</a>
Simple test.xql:
doc("test.xml")/a
Results:
C:\test>java net.sf.saxon.Query -t -catalog:didcat.xml test.xql
Loading catalog: didcat.xml
Saxon-HE 9.7.0.7J from Saxonica
Java version 1.8.0_101
Analyzing query from test.xql
Analysis time: 131.650519 milliseconds
Resolved URI: test.xml
file:/C:/test/test.xml
Building tree for file:/C:/test/test.xml using class net.sf.saxon.tree.tiny.TinyBuilder
Error on line 2 column 6 of test.xql:
FODC0002: I/O error reported by XML parser processing file:/C:/test/test.xml:
C:\test\bad.dtd (The system cannot find the file specified)
Query failed with dynamic error: I/O error reported by XML parser processing file:/C:/test/test.xml: C:\test\bad.dtd (The system cannot find the file specified)
I tried a few different catalog techniques to override the DTD URI but none were successful. What am I doing wrong? Thanks in advance.
To resolve references to XML entities such as DTDs, you need to use the systemSuffix entry in the catalog, not the uriSuffix entry. Change your catalog to
<catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog">
<systemSuffix systemSuffix="bad.dtd" uri="good.dtd" />
</catalog>

using curl, shell scripting how to upload all the files in Specific path to host?

i have written a script to upload all the files from a specific folder in local to the host, but there was some issue and the files are not getting uploaded to the host.
#!/bin/sh
for i in /main/folder_1/path/*
do
curl -u Pass:"Uname" -T $i http://www.example.com/folder/path/$i
done
echo "*****File Uplodaed ******"
help me to solve this. the following is the error, that i got
<html>
<head>
<title> 500 Internal Server Error </title>
</head>
<body>
<h1>
Internal Server Error
</h1>
</body>
</html>
currently i am having the script inside /main/folder_2, if i change /main/folder_1/path/ to ../folder_1/path/, i got the output as the files are moved. but i want to run the script with the complete path specified.

Application Cache Error event: Manifest fetch failed (404) why?

So my appcache is giving this error:
http://nl.tinypic.com/view.php?pic=23uv5eo&s=8#.VGUTs_mG9Zw
My file structure looks like this:
http://nl.tinypic.com/view.php?pic=2yw73oi&s=8#.VGUUXvmG9Zw
My HTML tag:
<html manifest="manifest.appcache" xmlns="http://www.w3.org/1999/xhtml">
Manifest.appcache
CACHE MANIFEST
CACHE:
/images/header/buttonIn.png
/images/header/buttonOut.png
NETWORK:
*
Why am i getting error i'm getting?
Can someone please for once and for all explain to me how to make a file with a .appcache extension? so much unclarity about this.
Since you run an apache server. Try adding AddType text/cache-manifest .appcache to your .htaccess file.
More info about this at this blog post

Resources