File: validate.sh

package info (click to toggle)
installation-guide 20130503
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 32,568 kB
  • sloc: xml: 100,872; sh: 1,090; perl: 421; awk: 199; makefile: 112; python: 101
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