Project

Profile

Help

xhtml/HTTP 503/Saxon9 error (java,Windows XP)

Added by Anonymous about 14 years ago

Legacy ID: #8063971 Legacy Poster: Phil Pfeiffer (phil-pf)

I've been trying to use Saxon9-B or Saxon9-HE to run XSLT 2.0 codes on XHTML files on a Windows XP platform. Unforutnately, I've been getting the java.IOexception "HTTP 503" error for my troubles. After some digging, I've determined that the problem involves my Java run-time environment's trying to contact http://www.w3.org/ to access the XHTML DTD, http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd. I understand why this is a bad thing, and have seen suggestions for coding hacks that Java developers can use to get the JRE to read the DTD from one's local host. The problem that I'm having is that my Java expertise is rather limited. I don't really need to write any Java to manage these tasks. I "only" need (and want) to use Saxon to run my XSLT programs on XHTML. Moreover, I have enough xhtml pages to manage that it would be really nice to "simply" run these programs on the source files directly, without having to implement workarounds: e.g., editing out the !DOCTYPE headers by hand and transforming them back in, or using a script that finds all .xhtml files in a directory tree, then uses tail or awk or some such to preprocess out the initila !DOCTYPE. Does anyone have any suggestions as to how to get Java on Windows, when applied to saxon9.jar, to do the right thing and validate against a local copy of the http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd DTD? Appreciativley, -- Phil


Replies (5)

Please register to reply

RE: xhtml/HTTP 503/Saxon9 error (java,Windows XP) - Added by Anonymous about 14 years ago

Legacy ID: #8064324 Legacy Poster: Michael Kay (mhkay)

You don't need to do any Java programming for this, but it can be a bit fiddly all the same. You need to install the Oasis catalog resolver, make a local copy of the DTD, set up a catalog that tells the XML parser where to find the local copy of the DTD, and then invoke Saxon in such a way that it uses the catalog. There are several descriptions on the web of how to do this: see for example https://sourceforge.net/apps/mediawiki/saxon/index.php?title=XML_Catalogs http://www.dpawson.co.uk/docbook/setup/cust.catalog.html http://www.scriptorium.com/blog/tag/saxon-9b Feel free to add to the Wiki page if you feel it can be improved.

RE: xhtml/HTTP 503/Saxon9 error (java,Windows XP) - Added by Anonymous about 14 years ago

Legacy ID: #8065807 Legacy Poster: Phil Pfeiffer (phil-pf)

Thank you so much, Mr. Kay, for taking the time to respond to my request for help. You were right about the process being fiddly. It took me about 4 hours to figure out what these pages were telling me, in part because they don't quite provide "Mr. Potato Head"-level documentation for non-Java users ... and in part because the promised .bat file on the scriptorium site wasn't there. I've written a .bat file that attempts to document the process more thoroughly. Since I'm like Hercule Poirot when it comes to ordering code, the file includes a BSD disclaimer, environment variables, command-line parameter checks, environment checks, error messages, and the setting of exit codes, along with a detailed synopsis of environmental prerequistes and URLs for more information. I'd be happy to post it to this board-- or append it to https://sourceforge.net/apps/mediawiki/saxon/index.php?title=XML_Catalogs -- but I wanted to ask what you thought would be approriate to do first. Again, thanks for the help - it's most appreciated. =================== Phil Pfeiffer/ East TN State U. | Kindness in thought leads to wisdom. Dept. of CIS / P.O. Box 70711 | Kindness in speech leads to eloquence. Johnson City, TN. 37614-1266 | Kindness in action leads to love. phil @ etsu.edu (423) 439-5355 | -- Lao-Tzu

RE: xhtml/HTTP 503/Saxon9 error (java,Windows XP) - Added by Anonymous about 14 years ago

Legacy ID: #8066913 Legacy Poster: Michael Kay (mhkay)

Glad you got it working. It sounds as if your script would be a great addition to the Wiki page. Michael Kay

RE: xhtml/HTTP 503/Saxon9 error (java,Windows XP) - Added by Anonymous about 14 years ago

Legacy ID: #8067001 Legacy Poster: Phil Pfeiffer (phil-pf)

Thanks again for responding. Since I don't have direct access to the wiki and am not sure how to submit to the Wiki, I'll post the script here, and allow the editors to do with it what they will. @REM Copyright (c) 2010, East Tennessee State University, Johnson City, TN. and Phil Pfeiffer. All rights reserved. @REM Redistribution and use in source form, with or without modification, is permitted provided that the following conditions are met: @REM *. Redistributions of this script must retain the above copyright notice, this list of conditions and the following disclaimer. @REM *. Neither the name of Phil Pfeiffer, nor that of ETSU, nor the names of ETSU's contributors may be used to endorse or promote @REM products derived from this software without specific prior written permission. @REM @REM THIS SOFTWARE IS PROVIDED BY ETSU AND PHIL PFEIFFER''AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, @REM INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR @REM PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ETSU OR PHIL PFEIFFER BE LIABLE FOR ANY DIRECT, INDIRECT, @REM INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT @REM OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER @REM CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING @REM NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THISSOFTWARE, EVEN IF ADVISED OF @REM THE POSSIBILITY OF SUCH DAMAGE. @REM ************************************************************************************** @REM run the Saxon XSLT language translation tool on a user-specified program/input pair, @REM with the OASIS catalogue resolver @REM @REM author: Phil Pfeiffer @REM date: February, 2010 @REM @REM Inputs: @REM 1st - name of stylesheet, quoted (required) @REM 2nd - name of stylesheet input document, quoted (required) @REM 3rd - name of file for capturing output, quoted (required) @REM @REM Hard-wired config parameters (defined by a set statement below): @REM DTD-catalogue - the pathname for an Oasis-style DTD catalogue @REM @REM Return values: a status code -- @REM 0 for success, 1 for parameter error, 2 for environment errors, 3 for execution errors @REM @REM Typical usage: @REM this_script.bat "some stylesheet.xsl" "some input.xhtml" "some output.xhtml" @REM @REM Notes: @REM -. quoting of inputs is required to allow for filenames with embedded whitespace @REM @REM -. This .bat file invokes Java on Saxon with a command that directs Java to use the OASIS catalogue @REM resolver to retrieve the xhtml1-strict.dtd from the local platform, rather than www.w3c.org. This @REM is needed to ensure the successful processing of XHTML files with initial !DOCTYPE definitions. @REM Some years ago, the W3C blocked access to xhtml1-strict.dtd from its web site to protect itself @REM from excessive server traffic. Users are now expected to download and access this DTD locally. @REM @REM In order for this command file to operate correctly, run it on a Windows platform whose environment @REM has been configured as follows: @REM -. theSaxon-HE interpreter must be downloaded from the Saxon sourceForge site and the location @REM of its .jar file added to the current platform's Classpath environment variable @REM -. the OASIS catalogue resolver, resolver.jar, must be downloaded from the Apache project and @REM its location added to the current platform's Classpath @REM -. a copy of xhtml1-strict.dtd must be downloaded from the W3C website, and placed in a local @REM directory with its three supporting files: xhtml-lat1.ent, xhtml-special.ent, and xhtml-symbol.ent. @REM -. an OASIS-formatted XML catalogue file, here called xhtml-dtd-catalogue.xml, must be installed @REM locally, with a top-level element of the form @REM @REM where system is resolved against the "urn:oasis:names:tc:entity:xmlns:xml:catalog" namespace @REM and the uri attribute references the downloaded copy of xhtml1-strict.dtd @REM @REM Resources: @REM -. http://saxon.sourceforge.net/ - home page for Saxon XSLT processors @REM -. https://sourceforge.net/apps/mediawiki/saxon/index.php?title=XML_Catalogs @REM Documentation on Apache's XML Commons Resolver and how to use it @REM (including a sample Oasis resolver configuration file for the XHTML DTD) @REM -. http://xml.apache.org/mirrors.cgi#binary @REM link to a mirror that has the binary versions of the XML Commons Resolvere @REM -. http://www.w3.org/TR/xhtml1 ; http://www.w3.org/TR/xhtml1/xhtml1.zip @REM links to the W3C's XHTML documentation page and a .zip of xhtml DTDs, including xhtml1-strict.dtd @REM -. network search engines - for step-by-step procedures for altering a Windows platform's :CLASSPATH: @REM (procedures vary depending on Windows platform) @REM ************************************************************************************** @REM setlocal - export none of the variables that this .bat file sets to the .bat file's execution environment @REM set errorlevel= a must for retrieving command status; if errorlevel defined, cmd won't overwrite errorlevel @setlocal @set errorlevel= @REM ################################################################ @REM environmental parameters @REM ################################################################ @REM locations of key locally resident files @set DTD-catalogue=C:\Program Files\Java\xml-commons-resolver-1.2\xhtml-dtd-catalogue.xml @REM command parameter aliases for Java/Saxon @set java_oasisopts="-Dxml.catalog.files=%DTD-catalogue%" @set saxon_command=net.sf.saxon.Transform @set saxon_oasisopts=-r:org.apache.xml.resolver.tools.CatalogResolver -x:org.apache.xml.resolver.tools.ResolvingXMLReader -y:org.apache.xml.resolver.tools.ResolvingXMLReader @REM ##################################### @REM program proper @REM ##################################### @REM ======================================================= @REM validate parameters; assign aliases for parameters @REM ======================================================= @set parameterCheckSucceeded=true @set param=%1 @if defined %param ( set stylesheet=%1% if "%param:~1,-1%"=="" ( echo %~n0: ?? malformed first [stylesheet] parameter [%param%]: must be a nonempty, quoted string set parameterCheckSucceeded=false ) ) else ( echo %~n0: ?? missing first [stylesheet] parameter [%param%]: must be a nonempty, quoted string set parameterCheckSucceeded=false ) @set param=%2 @if defined %param ( set inputFile=%2% if "%param:~1,-1%"=="" ( echo %~n0: ?? malformed second [input file] parameter [%param%]: must be a nonempty, quoted string set parameterCheckSucceeded=false ) ) else ( echo %~n0: ?? missing second [input file] parameter [%param%]: must be a nonempty, quoted string set parameterCheckSucceeded=false ) @set param=%3 @if defined %param ( set outputFile=%3% if "%param:~1,-1%"=="" ( echo %~n0: ?? malformed third [output file] parameter [%param%]: must be a nonempty, quoted string set parameterCheckSucceeded=false ) ) else ( set outputFile=con ) @REM -------------------------------------------------------- @REM parameter check complete: quit if anything awry @REM -------------------------------------------------------- @if %parameterCheckSucceeded%==false ( echo ?? %~n0: parameters check failed; exiting goto fatalError1 ) @REM ======================================================= @REM validate operating environment @REM ======================================================= @set environmentCheckSucceeded=true @REM ----------------------------------------------------------------------------------------------- @REM check for supporting utilities and files @REM ----------------------------------------------------------------------------------------------- @if NOT exist "%DTD-catalogue%" ( echo ?? %~n0: can't find command-file-specified DTD catalogue ["%DTD-catalogue%"] set environmentCheckSucceeded=false ) @if NOT exist %stylesheet% ( echo ?? %~n0: can't find specified stylesheet ["%stylesheet%"] set environmentCheckSucceeded=false ) @if NOT exist %inputFile% ( echo ?? %~n0: can't find specified input file ["%inputFile%"] set environmentCheckSucceeded=false ) @REM ---------------------------------------------------------------------------------- @REM Other assumptions not checked here @REM -. java.exe --- must be accessible via Path @REM -. saxon9.exe --- must be installed in a directory that's named in the current platform's Classpath @REM -. resolver.jar --- must be installed in a directory that's named in the current platform's Classpath @REM - xhtml-lat1.ent, xhtml-special.ent, and xhtml-symbol.ent -- must be placed in the same directory with xhtml1-strict.dtd @REM ---------------------------------------------------------------------------------- @REM ------------------------------------------------------- @REM environment check complete: quit if anything awry @REM ------------------------------------------------------- @if %environmentCheckSucceeded%==false ( echo ?? %~n0: environment check failed; exiting @goto fatalError2 ) @REM ======================================================= @REM script main @REM ======================================================= java %java_oasisopts% %saxon_command% %saxon_oasisopts% -xsl:%stylesheet% -s:%inputFile% -o:%outputFile% @if not %errorlevel% equ 0 goto fatalError3 @REM ============================================= @REM script exit points @REM ============================================= @endlocal @set errorlevel=0 @exit /B :fatalError1 @endlocal @set errorlevel=1 @exit /B :fatalError2 @endlocal @set errorlevel=2 @exit /B :fatalError3 @endlocal @set errorlevel=3 @exit /B

RE: xhtml/HTTP 503/Saxon9 error (java,Windows XP) - Added by Anonymous about 14 years ago

Legacy ID: #8067122 Legacy Poster: Michael Kay (mhkay)

Thanks for supplying this script. I've added a link to it from the Wiki page.

    (1-5/5)

    Please register to reply