File: validate.sh

package info (click to toggle)
installation-guide 20070319
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 29,356 kB
  • ctags: 53
  • sloc: xml: 184,383; sh: 1,023; perl: 403; awk: 200; makefile: 65
file content (22 lines) | stat: -rwxr-xr-x 600 bytes parent folder | download | duplicates (12)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#!/bin/sh

catalog=/usr/share/sgml/docbook/dtd/xml/4.2/catalog
xmldcl=/usr/share/sgml/declaration/xml.dcl
err=`tempfile`

if grep -q '^<!DOCTYPE' $1; then
  nsgmls -s -c $catalog $xmldcl $1 2> $err
else
  temp=`tempfile`
  topdir=`dirname $0`
  root=`sed -e '0,/<[a-z]/!d' $1 | sed -e '$!d' | sed -e 's/<\([a-z][a-zA-Z0-9]*\).*/\1/'`
  cat > $temp <<EOT
<!DOCTYPE $root PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN" "docbookx.dtd"   
[<!ENTITY % entities       SYSTEM "entities.ent"> %entities;]>
EOT
  cat $1 >> $temp
  nsgmls -s -D$topdir -c $catalog $xmldcl $temp 2> $err
  rm -f $temp
fi

less $err