" Vim indent file
-" Language: DTD (Document Type Definition for XML)
-" Maintainer: Nikolai Weibull <now@bitwi.se>
-" Latest Revision: 2011-07-08
+" Language: DTD (Document Type Definition for XML)
+" Previous Maintainer: Nikolai Weibull <now@bitwi.se>
+" Latest Revision: 2011-07-08
let s:cpo_save = &cpo
set cpo&vim
let [declaration, end] = s:lex1(line, col)
if declaration == ""
- return indent + &sw
+ return indent + shiftwidth()
elseif declaration == '--'
" We’re looking at a comment. Now, simply determine if the comment is
" terminated or not. If it isn’t, let Vim take care of that using
" Check for element name. If none exists, indent one level.
let [name, end] = s:lex(line, end)
if name == ""
- return indent + &sw
+ return indent + shiftwidth()
endif
" Check for token following element name. This can be a specification of
let n += 1
endwhile
if token == ""
- return indent + &sw
+ return indent + shiftwidth()
endif
" Next comes the content model. If the token we’ve found isn’t a
return indent
endif
" TODO: Should use s:lex here on getline(v:lnum) and check for >.
- return getline(v:lnum) =~ '^\s*>' || count(values(seen), 0) == 0 ? indent : (indent + &sw)
+ return getline(v:lnum) =~ '^\s*>' || count(values(seen), 0) == 0 ? indent : (indent + shiftwidth())
endif
" If we’ve seen an addition or exception already and this is of the same
" Check for element name. If none exists, indent one level.
let [name, end] = s:lex(line, end)
if name == ""
- return indent + &sw
+ return indent + shiftwidth()
endif
" Check for any number of attributes.
let [name, end] = s:lex(line, end)
if name == ""
" TODO: Should use s:lex here on getline(v:lnum) and check for >.
- return getline(v:lnum) =~ '^\s*>' ? indent : (indent + &sw)
+ return getline(v:lnum) =~ '^\s*>' ? indent : (indent + shiftwidth())
elseif name == ">"
return indent
endif
" (CDATA|NMTOKEN|NMTOKENS|ID|IDREF|IDREFS|ENTITY|ENTITIES)?
let [value, end] = s:lex(line, end, '^\%((\|[^[:space:]]\+\)')
if value == ""
- return indent + &sw * 2
+ return indent + shiftwidth() * 2
elseif value == 'NOTATION'
" If this is a enumerated value based on notations, read another token
" for the actual value. If it doesn’t exist, indent three levels.
" TODO: If validating according to above, value must be equal to '('.
let [value, end] = s:lex(line, end, '^\%((\|[^[:space:]]\+\)')
if value == ""
- return indent + &sw * 3
+ return indent + shiftwidth() * 3
endif
endif
" two levels.
let [default, end] = s:lex(line, end, '^\%("\_[^"]*"\|#\(REQUIRED\|IMPLIED\|FIXED\)\)')
if default == ""
- return indent + &sw * 2
+ return indent + shiftwidth() * 2
elseif default == '#FIXED'
" We need to look for the fixed value. If non exists, indent three
" levels.
let [default, end] = s:lex(line, end, '^"\_[^"]*"')
if default == ""
- return indent + &sw * 3
+ return indent + shiftwidth() * 3
endif
endif
endwhile
" again, if none exists, indent one level.
let [name, end] = s:lex(line, end)
if name == ""
- return indent + &sw
+ return indent + shiftwidth()
elseif name == '%'
let [name, end] = s:lex(line, end)
if name == ""
- return indent + &sw
+ return indent + shiftwidth()
endif
endif
" we’re now done with this entity.
let [value, end] = s:lex(line, end)
if value == ""
- return indent + &sw
+ return indent + shiftwidth()
elseif value == 'SYSTEM' || value == 'PUBLIC'
let [quoted_string, end] = s:lex(line, end, '\%("[^"]\+"\|''[^'']\+''\)')
if quoted_string == ""
- return indent + &sw * 2
+ return indent + shiftwidth() * 2
endif
if value == 'PUBLIC'
let [quoted_string, end] = s:lex(line, end, '\%("[^"]\+"\|''[^'']\+''\)')
if quoted_string == ""
- return indent + &sw * 2
+ return indent + shiftwidth() * 2
endif
endif
let [ndata, end] = s:lex(line, end)
if ndata == ""
- return indent + &sw
+ return indent + shiftwidth()
endif
let [name, end] = s:lex(line, end)
- return name == "" ? (indent + &sw * 2) : indent
+ return name == "" ? (indent + shiftwidth() * 2) : indent
else
return indent
endif
" Check for notation name. If none exists, indent one level.
let [name, end] = s:lex(line, end)
if name == ""
- return indent + &sw
+ return indent + shiftwidth()
endif
" Now check for the external ID. If none exists, indent one level.
let [id, end] = s:lex(line, end)
if id == ""
- return indent + &sw
+ return indent + shiftwidth()
elseif id == 'SYSTEM' || id == 'PUBLIC'
let [quoted_string, end] = s:lex(line, end, '\%("[^"]\+"\|''[^'']\+''\)')
if quoted_string == ""
- return indent + &sw * 2
+ return indent + shiftwidth() * 2
endif
if id == 'PUBLIC'
let [quoted_string, end] = s:lex(line, end, '\%("[^"]\+"\|''[^'']\+''\|>\)')
if quoted_string == ""
" TODO: Should use s:lex here on getline(v:lnum) and check for >.
- return getline(v:lnum) =~ '^\s*>' ? indent : (indent + &sw * 2)
+ return getline(v:lnum) =~ '^\s*>' ? indent : (indent + shiftwidth() * 2)
elseif quoted_string == '>'
return indent
endif