docbook-xml.kur-kos 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511
  1. #!/bin/sh
  2. # create XML catalog with initial docbook-xml catalog
  3. if [ ! -e /etc/xml/catalog ]
  4. then
  5. xmlcatalog --noout --create /etc/xml/docbook
  6. fi
  7. xmlcatalog --noout --add "public" \
  8. "-//OASIS//DTD DocBook XML V4.5//EN" \
  9. "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" \
  10. /etc/xml/docbook &&
  11. xmlcatalog --noout --add "public" \
  12. "-//OASIS//DTD DocBook XML CALS Table Model V4.5//EN" \
  13. "file:///usr/share/xml/docbook/xml-dtd-4.5/calstblx.dtd" \
  14. /etc/xml/docbook &&
  15. xmlcatalog --noout --add "public" \
  16. "-//OASIS//DTD XML Exchange Table Model 19990315//EN" \
  17. "file:///usr/share/xml/docbook/xml-dtd-4.5/soextblx.dtd" \
  18. /etc/xml/docbook &&
  19. xmlcatalog --noout --add "public" \
  20. "-//OASIS//ELEMENTS DocBook XML Information Pool V4.5//EN" \
  21. "file:///usr/share/xml/docbook/xml-dtd-4.5/dbpoolx.mod" \
  22. /etc/xml/docbook &&
  23. xmlcatalog --noout --add "public" \
  24. "-//OASIS//ELEMENTS DocBook XML Document Hierarchy V4.5//EN" \
  25. "file:///usr/share/xml/docbook/xml-dtd-4.5/dbhierx.mod" \
  26. /etc/xml/docbook &&
  27. xmlcatalog --noout --add "public" \
  28. "-//OASIS//ELEMENTS DocBook XML HTML Tables V4.5//EN" \
  29. "file:///usr/share/xml/docbook/xml-dtd-4.5/htmltblx.mod" \
  30. /etc/xml/docbook &&
  31. xmlcatalog --noout --add "public" \
  32. "-//OASIS//ENTITIES DocBook XML Notations V4.5//EN" \
  33. "file:///usr/share/xml/docbook/xml-dtd-4.5/dbnotnx.mod" \
  34. /etc/xml/docbook &&
  35. xmlcatalog --noout --add "public" \
  36. "-//OASIS//ENTITIES DocBook XML Character Entities V4.5//EN" \
  37. "file:///usr/share/xml/docbook/xml-dtd-4.5/dbcentx.mod" \
  38. /etc/xml/docbook &&
  39. xmlcatalog --noout --add "public" \
  40. "-//OASIS//ENTITIES DocBook XML Additional General Entities V4.5//EN" \
  41. "file:///usr/share/xml/docbook/xml-dtd-4.5/dbgenent.mod" \
  42. /etc/xml/docbook &&
  43. xmlcatalog --noout --add "rewriteSystem" \
  44. "http://www.oasis-open.org/docbook/xml/4.5" \
  45. "file:///usr/share/xml/docbook/xml-dtd-4.5" \
  46. /etc/xml/docbook &&
  47. xmlcatalog --noout --add "rewriteURI" \
  48. "http://www.oasis-open.org/docbook/xml/4.5" \
  49. "file:///usr/share/xml/docbook/xml-dtd-4.5" \
  50. /etc/xml/docbook
  51. if [ ! -e /etc/xml/catalog ]; then
  52. xmlcatalog --noout --create /etc/xml/catalog
  53. fi &&
  54. xmlcatalog --noout --add "delegatePublic" \
  55. "-//OASIS//ENTITIES DocBook XML" \
  56. "file:///etc/xml/docbook" \
  57. /etc/xml/catalog &&
  58. xmlcatalog --noout --add "delegatePublic" \
  59. "-//OASIS//DTD DocBook XML" \
  60. "file:///etc/xml/docbook" \
  61. /etc/xml/catalog &&
  62. xmlcatalog --noout --add "delegateSystem" \
  63. "http://www.oasis-open.org/docbook/" \
  64. "file:///etc/xml/docbook" \
  65. /etc/xml/catalog &&
  66. xmlcatalog --noout --add "delegateURI" \
  67. "http://www.oasis-open.org/docbook/" \
  68. "file:///etc/xml/docbook" \
  69. /etc/xml/catalog
  70. for DTDVERSION in 4.1.2 4.2 4.3 4.4
  71. do
  72. xmlcatalog --noout --add "public" \
  73. "-//OASIS//DTD DocBook XML V$DTDVERSION//EN" \
  74. "http://www.oasis-open.org/docbook/xml/$DTDVERSION/docbookx.dtd" \
  75. /etc/xml/docbook
  76. xmlcatalog --noout --add "rewriteSystem" \
  77. "http://www.oasis-open.org/docbook/xml/$DTDVERSION" \
  78. "file:///usr/share/xml/docbook/xml-dtd-4.5" \
  79. /etc/xml/docbook
  80. xmlcatalog --noout --add "rewriteURI" \
  81. "http://www.oasis-open.org/docbook/xml/$DTDVERSION" \
  82. "file:///usr/share/xml/docbook/xml-dtd-4.5" \
  83. /etc/xml/docbook
  84. xmlcatalog --noout --add "delegateSystem" \
  85. "http://www.oasis-open.org/docbook/xml/$DTDVERSION/" \
  86. "file:///etc/xml/docbook" \
  87. /etc/xml/catalog
  88. xmlcatalog --noout --add "delegateURI" \
  89. "http://www.oasis-open.org/docbook/xml/$DTDVERSION/" \
  90. "file:///etc/xml/docbook" \
  91. /etc/xml/catalog
  92. done
  93. #! /bin/bash
  94. usage()
  95. {
  96. cat <<EOF
  97. Usage: $pname [OPTION]
  98. Known values for OPTION are:
  99. --prefix=DIR change the output directory for catalog files
  100. [default $DIR]
  101. --show display the output filenames and paths
  102. --version=x.y.z change the DocBook version [default $VERSION]
  103. --debug display script action information
  104. --help display this help and exit
  105. EOF
  106. }
  107. setdefault()
  108. {
  109. echo Unable to update root catalog $ROOTCATALOG
  110. ROOTCATALOG=$HOME/xmlcatalog
  111. CATALOG=$HOME/dbkxmlcatalog
  112. DIR=$HOME
  113. CAT=xmlcatalog
  114. echo Using $ROOTCATALOG as the root catalog
  115. echo Remember to export XML_CATALOG_FILES=$ROOTCATALOG
  116. echo
  117. prefix=1
  118. }
  119. fixname()
  120. {
  121. #
  122. # ROOTCATALOG contains the full pathname for the catalog. We will
  123. # split that into the directory name and the filename, then we will
  124. # see if the directory exists. If it does not, we will attempt to
  125. # create it.
  126. #
  127. if test $verbose = 1
  128. then
  129. echo Checking path $ROOTCATALOG for permissions
  130. fi
  131. # First we split the filename and directory name
  132. CAT=`basename $ROOTCATALOG`
  133. DIR=`dirname $ROOTCATALOG`
  134. if test "$DIR" = ""
  135. then
  136. echo Unable to isolate directory name from '$ROOTCATALOG' - exiting
  137. exit 1
  138. fi
  139. CATALOG=${DIR}/docbook
  140. parent=`dirname $DIR`
  141. if test "$parent" == ""
  142. then
  143. parent=/
  144. fi
  145. if [ ! -d $DIR ]
  146. then
  147. if test $verbose = 1
  148. then
  149. echo Directory $DIR missing - I will try to create it
  150. fi
  151. if [ ! -w $parent ]
  152. then
  153. if test $verbose = 1
  154. then
  155. echo No write permission for directory $parent
  156. fi
  157. setdefault
  158. else
  159. newdir=1
  160. fi
  161. else
  162. if [ -f $ROOTCATALOG -a ! -w $ROOTCATALOG ] ||
  163. [ -e $ROOTCATALOG -a ! -f $ROOTCATALOG ] ||
  164. [ ! -e $ROOTCATALOG -a ! -w $DIR ]
  165. then
  166. setdefault
  167. fi
  168. fi
  169. }
  170. finddbx()
  171. {
  172. dtd421=""
  173. s="//OASIS//DTD DocBook XML V${VERSION}//EN"
  174. found=`find $1 -name docbookx.dtd -exec grep -l "$s" {} \;`
  175. for dtd in $found; do
  176. docbookdir=`dirname $dtd`
  177. echo Found DocBook XML $VERSION DTD in $docbookdir
  178. #
  179. # The original script had a check for write permission on the file
  180. # but I can't see why it should be necessary
  181. #
  182. dtd421=$dtd
  183. break
  184. done
  185. }
  186. #
  187. # Preset script control params
  188. show=0
  189. prefix=0
  190. newdir=0
  191. verbose=0
  192. #
  193. # Isolate the script name for messages
  194. pisim=`basename $0`
  195. VERSION=4.1.2
  196. if test "$XML_CATALOG_FILES" != ""
  197. then
  198. ROOTCATALOG=$XML_CATALOG_FILES
  199. else
  200. ROOTCATALOG=/etc/xml/catalog
  201. fi
  202. #
  203. # Interpret script parameters
  204. while test $# -gt 0; do
  205. case "$1" in
  206. -*=*) optarg=`echo "$1" | sed 's/[-_a-zA-Z0-9]*=//'` ;;
  207. *) optarg= ;;
  208. esac
  209. case "$1" in
  210. -p=* | --prefix=*)
  211. ROOTCATALOG=$optarg/catalog
  212. prefix=1
  213. ;;
  214. -s | --show)
  215. show=1
  216. ;;
  217. -v=* | --version=*)
  218. VERSION=$optarg
  219. ;;
  220. -d | --debug)
  221. verbose=1
  222. ;;
  223. -h | --help)
  224. usage
  225. exit 0
  226. ;;
  227. * )
  228. echo Invalid argument "$1"
  229. usage
  230. exit 1
  231. ;;
  232. esac
  233. shift
  234. done
  235. fixname
  236. if test $prefix != 0
  237. then
  238. export XML_CATALOG_FILES=$ROOTCATALOG
  239. fi
  240. if test $show != 0
  241. then
  242. echo XML Catalog is $ROOTCATALOG
  243. echo Docbook Catalog is $CATALOG
  244. exit 0
  245. fi
  246. if test $newdir!=0
  247. then
  248. mkdir -p $DIR
  249. chmod 755 $DIR
  250. fi
  251. echo Starting run
  252. #
  253. # create the catalogs root and docbook specific
  254. #
  255. if [ ! -r $ROOTCATALOG ] ; then
  256. echo creating XML Catalog root $ROOTCATALOG
  257. xmlcatalog --noout --create $ROOTCATALOG
  258. fi
  259. if [ ! -r $ROOTCATALOG ] ; then
  260. echo Failed creating XML Catalog root $ROOTCATALOG
  261. exit 1
  262. fi
  263. if [ ! -r $CATALOG ] ; then
  264. echo creating DocBook XML Catalog $CATALOG
  265. xmlcatalog --noout --create $CATALOG
  266. fi
  267. if [ ! -r $CATALOG ] ; then
  268. echo Failed creating DocBook XML Catalog $CATALOG
  269. exit 1
  270. fi
  271. #
  272. # find the prefix for DocBook DTD
  273. #
  274. finddbx /usr/share/xml
  275. if [ "$dtd421" = "" ] ; then
  276. finddbx $HOME
  277. fi
  278. if [ "$dtd421" = "" ] ; then
  279. finddbx /usr/local
  280. fi
  281. if [ "$dtd421" = "" ] ; then
  282. finddbx /usr/share/sgml
  283. fi
  284. if [ "$dtd421" = "" ] ; then
  285. echo could not locate version $VERSION of DocBook XML
  286. exit 1
  287. fi
  288. xmlcatalog --noout --add "public" \
  289. "-//OASIS//ELEMENTS DocBook XML Information Pool V${VERSION}//EN" \
  290. "file://$docbookdir/dbpoolx.mod" $CATALOG
  291. xmlcatalog --noout --add "public" \
  292. "-//OASIS//DTD DocBook XML V${VERSION}//EN" \
  293. "file://$docbookdir/docbookx.dtd" $CATALOG
  294. xmlcatalog --noout --add "public" \
  295. "-//OASIS//ENTITIES DocBook XML Character Entities V${VERSION}//EN" \
  296. "file://$docbookdir/dbcentx.mod" $CATALOG
  297. xmlcatalog --noout --add "public" \
  298. "-//OASIS//ENTITIES DocBook XML Notations V${VERSION}//EN" \
  299. "file://$docbookdir/dbnotnx.mod" $CATALOG
  300. xmlcatalog --noout --add "public" \
  301. "-//OASIS//ENTITIES DocBook XML Additional General Entities V${VERSION}//EN" \
  302. "file://$docbookdir/dbgenent.mod" $CATALOG
  303. xmlcatalog --noout --add "public" \
  304. "-//OASIS//ELEMENTS DocBook XML Document Hierarchy V${VERSION}//EN" \
  305. "file://$docbookdir/dbhierx.mod" $CATALOG
  306. xmlcatalog --noout --add "public" \
  307. "-//OASIS//DTD XML Exchange Table Model 19990315//EN" \
  308. "file://$docbookdir/soextblx.dtd" $CATALOG
  309. xmlcatalog --noout --add "public" \
  310. "-//OASIS//DTD DocBook XML CALS Table Model V${VERSION}//EN" \
  311. "file://$docbookdir/calstblx.dtd" $CATALOG
  312. xmlcatalog --noout --add "rewriteSystem" \
  313. "http://www.oasis-open.org/docbook/xml/${VERSION}" \
  314. "file://$docbookdir" $CATALOG
  315. xmlcatalog --noout --add "rewriteURI" \
  316. "http://www.oasis-open.org/docbook/xml/${VERSION}" \
  317. "file://$docbookdir" $CATALOG
  318. xmlcatalog --noout --add "delegatePublic" \
  319. "-//OASIS//ENTITIES DocBook XML" \
  320. "file://$CATALOG" $ROOTCATALOG
  321. xmlcatalog --noout --add "delegatePublic" \
  322. "-//OASIS//DTD DocBook XML" \
  323. "file://$CATALOG" $ROOTCATALOG
  324. xmlcatalog --noout --add "delegateSystem" \
  325. "http://www.oasis-open.org/docbook/" \
  326. "file://$CATALOG" $ROOTCATALOG
  327. xmlcatalog --noout --add "delegateURI" \
  328. "http://www.oasis-open.org/docbook/" \
  329. "file://$CATALOG" $ROOTCATALOG
  330. #
  331. # find the prefix for ISO DocBook entities
  332. #
  333. top=`dirname $docbookdir`
  334. found=`find $top -name isoamsb.ent`
  335. if [ "$found" = "" ] ; then
  336. found=`find /usr/share/xml -name isoamsb.ent`
  337. fi
  338. if [ "$found" = "" ] ; then
  339. found=`find $HOME -name isoamsb.ent`
  340. fi
  341. if [ "$found" = "" ] ; then
  342. found=`find /usr/local -name isoamsb.ent`
  343. fi
  344. if [ "$found" = "" ] ; then
  345. found=`find /usr/share/sgml -name isoamsb.ent`
  346. fi
  347. if [ "$found" = "" ] ; then
  348. echo could not locate isoamsb.ent of ISO DocBook entities
  349. exit 1
  350. fi
  351. entxml=""
  352. for tst in $found; do
  353. check=`grep '<!ENTITY ominus' $tst`
  354. if [ "$check" != "" ] ; then
  355. entxml=$tst
  356. break
  357. fi
  358. done
  359. if [ "$entxml" = "" ] ; then
  360. echo could not locate ISO DocBook entities
  361. exit 1
  362. fi
  363. isodir=`dirname $entxml`
  364. echo Found ISO DocBook entities in $isodir
  365. xmlcatalog --noout --add "public" \
  366. "ISO 8879:1986//ENTITIES Publishing//EN" \
  367. "file://$isodir/isopub.ent" $CATALOG
  368. xmlcatalog --noout --add "public" \
  369. "ISO 8879:1986//ENTITIES Greek Letters//EN" \
  370. "file://$isodir/isogrk1.ent" $CATALOG
  371. xmlcatalog --noout --add "public" \
  372. "ISO 8879:1986//ENTITIES Box and Line Drawing//EN" \
  373. "file://$isodir/isobox.ent" $CATALOG
  374. xmlcatalog --noout --add "public" \
  375. "ISO 8879:1986//ENTITIES Greek Symbols//EN" \
  376. "file://$isodir/isogrk3.ent" $CATALOG
  377. xmlcatalog --noout --add "public" \
  378. "ISO 8879:1986//ENTITIES Added Math Symbols: Negated Relations//EN" \
  379. "file://$isodir/isoamsn.ent" $CATALOG
  380. xmlcatalog --noout --add "public" \
  381. "ISO 8879:1986//ENTITIES Numeric and Special Graphic//EN" \
  382. "file://$isodir/isonum.ent" $CATALOG
  383. xmlcatalog --noout --add "public" \
  384. "ISO 8879:1986//ENTITIES Alternative Greek Symbols//EN" \
  385. "file://$isodir/isogrk4.ent" $CATALOG
  386. xmlcatalog --noout --add "public" \
  387. "ISO 8879:1986//ENTITIES Diacritical Marks//EN" \
  388. "file://$isodir/isodia.ent" $CATALOG
  389. xmlcatalog --noout --add "public" \
  390. "ISO 8879:1986//ENTITIES Monotoniko Greek//EN" \
  391. "file://$isodir/isogrk2.ent" $CATALOG
  392. xmlcatalog --noout --add "public" \
  393. "ISO 8879:1986//ENTITIES Added Math Symbols: Arrow Relations//EN" \
  394. "file://$isodir/isoamsa.ent" $CATALOG
  395. xmlcatalog --noout --add "public" \
  396. "ISO 8879:1986//ENTITIES Added Math Symbols: Ordinary//EN" \
  397. "file://$isodir/isoamso.ent" $CATALOG
  398. xmlcatalog --noout --add "public" \
  399. "ISO 8879:1986//ENTITIES Russian Cyrillic//EN" \
  400. "file://$isodir/isocyr1.ent" $CATALOG
  401. xmlcatalog --noout --add "public" \
  402. "ISO 8879:1986//ENTITIES General Technical//EN" \
  403. "file://$isodir/isotech.ent" $CATALOG
  404. xmlcatalog --noout --add "public" \
  405. "ISO 8879:1986//ENTITIES Added Math Symbols: Delimiters//EN" \
  406. "file://$isodir/isoamsc.ent" $CATALOG
  407. xmlcatalog --noout --add "public" \
  408. "ISO 8879:1986//ENTITIES Added Latin 1//EN" \
  409. "file://$isodir/isolat1.ent" $CATALOG
  410. xmlcatalog --noout --add "public" \
  411. "ISO 8879:1986//ENTITIES Added Math Symbols: Binary Operators//EN" \
  412. "file://$isodir/isoamsb.ent" $CATALOG
  413. xmlcatalog --noout --add "public" \
  414. "ISO 8879:1986//ENTITIES Added Latin 2//EN" \
  415. "file://$isodir/isolat2.ent" $CATALOG
  416. xmlcatalog --noout --add "public" \
  417. "ISO 8879:1986//ENTITIES Added Math Symbols: Relations//EN" \
  418. "file://$isodir/isoamsr.ent" $CATALOG
  419. xmlcatalog --noout --add "public" \
  420. "ISO 8879:1986//ENTITIES Non-Russian Cyrillic//EN" \
  421. "file://$isodir/isocyr2.ent" $CATALOG
  422. xmlcatalog --noout --add "delegatePublic" \
  423. "ISO 8879:1986" \
  424. "file://$CATALOG" $ROOTCATALOG
  425. #
  426. # find the prefix for XSLT stylesheets
  427. #
  428. top=`dirname $docbookdir`
  429. found=`find $top -name chunk.xsl`
  430. if [ "$found" = "" ] ; then
  431. found=`find /usr/share/xml -name chunk.xsl`
  432. fi
  433. if [ "$found" = "" ] ; then
  434. found=`find $HOME -name chunk.xsl`
  435. fi
  436. if [ "$found" = "" ] ; then
  437. found=`find /usr/local -name chunk.xsl`
  438. fi
  439. if [ "$found" = "" ] ; then
  440. found=`find /usr/share/sgml -name chunk.xsl`
  441. fi
  442. if [ "$found" = "" ] ; then
  443. echo could not locate chunk-common.xsl of DocBook XSLT stylesheets
  444. exit 1
  445. fi
  446. xsldir=""
  447. for tst in $found; do
  448. dir=`dirname $tst`
  449. dir=`dirname $dir`
  450. if [ -r $dir/html/docbook.xsl -a -r $dir/common/l10n.xml ]; then
  451. xsldir=$dir
  452. break
  453. fi
  454. done
  455. if [ "$xsldir" = "" ] ; then
  456. echo could not locate DocBook XSLT stylesheets
  457. exit 1
  458. fi
  459. echo Found DocBook XSLT stylesheets in $xsldir
  460. for version in current 1.39 1.40 1.41 1.42 1.43 1.44 1.45 1.46 1.47 \
  461. 1.48 1.49 1.50
  462. do
  463. xmlcatalog --noout --add "rewriteSystem" \
  464. "http://docbook.sourceforge.net/release/xsl/$version" \
  465. "file://$xsldir" $CATALOG
  466. xmlcatalog --noout --add "rewriteURI" \
  467. "http://docbook.sourceforge.net/release/xsl/$version" \
  468. "file://$xsldir" $CATALOG
  469. done
  470. xmlcatalog --noout --add "delegateSystem" \
  471. "http://docbook.sourceforge.net/release/xsl/" \
  472. "file://$CATALOG" $ROOTCATALOG
  473. xmlcatalog --noout --add "delegateURI" \
  474. "http://docbook.sourceforge.net/release/xsl/" \
  475. "file://$CATALOG" $ROOTCATALOG
  476. #
  477. #