-
Notifications
You must be signed in to change notification settings - Fork 3
/
saxonb-neko.sh
executable file
·73 lines (69 loc) · 2.62 KB
/
saxonb-neko.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#!/usr/bin/env sh
#See http://saxon.sourceforge.net
#See http://sourceforge.net/projects/nekohtml/
#Internal variables
_thisDir=`dirname "$0"`
_libDir=$( cd "$_thisDir/../lib"; pwd )
_saxonbDir="$_libDir/saxonb-9.1.0.8j"
_xercesDir="$_libDir/apache-xerces-2.11.0"
_nekoDir="$_libDir/nekohtml-1.9.18"
_XMLCommonsDir="$_libDir/apache-commons-xml-external-1.4.01"
_resolverDir="$_libDir/apache-commons-xmlresolver-1.2"
_XMLCatalogDir=$( cd "$_thisDir/../../XMLCatalog" ; pwd )
#Check setup
if [ ! `which java 2> /dev/null` ]; then
echo "Error: Could not find java" > /dev/stderr
return
fi
if [ ! -d "$_libDir" ]; then
echo "Error: Could not find \"$_libDir\"" > /dev/stderr
return
fi
if [ ! -d "$_saxonbDir" ] || [ ! -s "$_saxonbDir/saxon9.jar" ]; then
echo "Error: Could not find \"$_saxonbDir/saxon9.jar\"" > /dev/stderr
return
fi
if [ ! -d "$_XMLCommonsDir" ] || [ ! -s "$_XMLCommonsDir/xml-apis.jar" ]; then
echo "Error: Could not find \"$_XMLCommonsDir/xml-apis.jar\"" > /dev/stderr
return
fi
if [ ! -d "$_XMLCommonsDir" ] || [ ! -s "$_XMLCommonsDir/xml-apis-ext.jar" ]; then
echo "Error: Could not find \"$_XMLCommonsDir/xml-apis-ext.jar\"" > /dev/stderr
return
fi
if [ ! -d "$_xercesDir" ] || [ ! -s "$_xercesDir/xercesImpl.jar" ]; then
echo "Error: Could not find \"$_xercesDir/xercesImpl.jar\"" > /dev/stderr
return
fi
if [ ! -d "$_nekoDir" ] || [ ! -s "$_nekoDir/nekohtml.jar" ]; then
echo "Error: Could not find \"$_nekoDir/nekohtml.jar\"" > /dev/stderr
return
fi
if [ ! -d "$_resolverDir" ] || [ ! -s "$_resolverDir/resolver.jar" ]; then
echo "Error: Could not find \"$_resolverDir/resolver.jar\"" > /dev/stderr
return
fi
if [ ! -d "$_XMLCatalogDir" ] || [ ! -s "$_XMLCatalogDir/catalog.xml" ]; then
echo "Error: Could not find \"$_XMLCatalogDir/catalog.xml\"" > /dev/stderr
return
fi
#Execute saxon command configured to use neko html sax parser
#See http://sourceforge.net/projects/nekohtml/
java \
-cp \
"$_saxonbDir/saxon9.jar":\
"$_xercesDir/xercesImpl.jar":\
"$_resolverDir/resolver.jar":\
"$_XMLCatalogDir":\
"$_nekoDir/nekohtml.jar"\
'-Dorg.xml.sax.driver=org.apache.xml.resolver.tools.ResolvingXMLReader' \
'-Djavax.xml.parsers.DocumentBuilderFactory=org.apache.xerces.jaxp.DocumentBuilderFactoryImpl' \
'-Djavax.xml.parsers.SAXParserFactory=org.apache.xerces.jaxp.SAXParserFactoryImpl' \
'-Dorg.apache.xerces.xni.parser.XMLParserConfiguration=org.apache.xerces.parsers.XIncludeParserConfiguration' \
net.sf.saxon.Transform \
-versionmsg:off \
-l:on \
-x:org.cyberneko.html.parsers.SAXParser \
-y:org.apache.xml.resolver.tools.ResolvingXMLReader \
-r:org.apache.xml.resolver.tools.CatalogResolver \
"$@"