#!/bin/sh set -e # This script comes from docbook2X. # Copyright (C) 2004 Steve Cheng # MIT license. sed_script=' # This sed script automatically adds the XML ISO entities # to the output from sgml2xml/sx/osx, so that # XML tools can be used readily on SGML (DocBook) documents. # Work around osx misfeature: # it has no option to just echo SDATA entities, # but insists on using PIs if one wants to preserve them s//\&\1;/ # Note that this DOCTYPE parsing is not really correct. # For example it cannot handle a DOCTYPE declaration # that is split across several lines. # But it works with the output from sx. /^\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ %ISOamsa;\ %ISOamsb;\ %ISOamsc;\ %ISOamsn;\ %ISOamso;\ %ISOamsr;\ %ISObox;\ %ISOcyr1;\ %ISOcyr2;\ %ISOdia;\ %ISOgrk1;\ %ISOgrk2;\ %ISOgrk3;\ %ISOgrk4;\ %ISOlat1;\ %ISOlat2;\ %ISOnum;\ %ISOpub;\ %ISOtech; }' sx_whining='W: reference to internal SDATA entity' # The purpose of the following slew of redirections # is to get the error messages in the right place # and to return sx/osx exit status. # (the sed and grep are unlikely to fail) # Prefer sx (sgml2xml) over osx because it is faster if test -x "@SX@"; then exec 3>&1 4>&2; status=`((("@SX@" -xid -xlower "$@"; echo $? >&5) | sed -e "$sed_script") 2>&1 1>&3 | grep -v "$sx_whining" 1>&4) 5>&1`; exit $status; elif test -x "@OSX@"; then exec 3>&1 4>&2; status=`(("@OSX@" -xid -xlower -xsdata-as-pis "$@"; echo $? >&5) | sed -e "$sed_script") 5>&1 2>&4 1>&3`; exit $status; else echo "$0: cannot find sx(sgml2xml) or osx to convert SGML to XML. Cannot continue." 2>&1 exit 255; fi