Permalink
Browse files

Removed legacy ext attribute

  • Loading branch information...
1 parent f6c5816 commit 5a4f323a29d4bdaf38f3d6b79e6243f6ba8002aa @oozcitak committed Dec 24, 2013
Showing with 43 additions and 59 deletions.
  1. +2 −7 src/XMLBuilder.coffee
  2. +14 −14 src/XMLDTDEntity.coffee
  3. +11 −11 src/XMLDTDNotation.coffee
  4. +8 −8 src/XMLDocType.coffee
  5. +8 −19 test/doctype.coffee
View
@@ -18,8 +18,8 @@ module.exports = class XMLBuilder
# `options.encoding` Encoding declaration, e.g. UTF-8
# `options.standalone` standalone document declaration: true or false
#
- # `options.pubID` public identifier of the external subset
- # `options.sysID` system identifier of the external subset
+ # `options.pubid` public identifier of the external subset
+ # `options.sysid` system identifier of the external subset
#
# `options.headless` whether XML declaration and doctype will be included: true or false
# `options.allowSurrogateChars` whether surrogates will be allowed: true or false
@@ -29,11 +29,6 @@ module.exports = class XMLBuilder
throw new Error "Root element needs a name"
options ?= {}
-
- # support legacy ext attribute
- if options.ext and not options.sysID
- options.sysID = options.ext
-
@stringify = new XMLStringifier options
# prolog
View
@@ -11,9 +11,9 @@ module.exports = class XMLDTDEntity
# defaults to `false` (general entity)
# `name` the name of the entity
# `value` internal entity value or an object with external entity details
- # `value.pubid` public identifier
- # `value.sysid` system identifier
- # `value.ndata` notation declaration
+ # `value.pubID` public identifier
+ # `value.sysID` system identifier
+ # `value.nData` notation declaration
constructor: (parent, pe, name, value) ->
@stringify = parent.stringify
@@ -28,16 +28,16 @@ module.exports = class XMLDTDEntity
if not _.isObject value
@value = @stringify.dtdEntityValue value
else
- if not value.pubid and not value.sysid
+ if not value.pubID and not value.sysID
throw new Error "Public and/or system identifiers are required for an external entity"
- if value.pubid and not value.sysid
+ if value.pubID and not value.sysID
throw new Error "System identifier is required for a public external entity"
- @pubid = @stringify.dtdPubID value.pubid if value.pubid?
- @sysid = @stringify.dtdSysID value.sysid if value.sysid?
+ @pubID = @stringify.dtdPubID value.pubID if value.pubID?
+ @sysID = @stringify.dtdSysID value.sysID if value.sysID?
- @ndata = @stringify.dtdNData value.ndata if value.ndata?
- if @pe and @ndata
+ @nData = @stringify.dtdNData value.nData if value.nData?
+ if @pe and @nData
throw new Error "Notation declaration is not allowed in a parameter entity"
@@ -64,11 +64,11 @@ module.exports = class XMLDTDEntity
if @value
r += ' "' + @value + '"'
else
- if @pubid and @sysid
- r += ' PUBLIC "' + @pubid + '" "' + @sysid + '"'
- else if @sysid
- r += ' SYSTEM "' + @sysid + '"'
- r += ' NDATA ' + @ndata if @ndata
+ if @pubID and @sysID
+ r += ' PUBLIC "' + @pubID + '" "' + @sysID + '"'
+ else if @sysID
+ r += ' SYSTEM "' + @sysID + '"'
+ r += ' NDATA ' + @nData if @nData
r += '>'
r += newline if pretty
View
@@ -9,19 +9,19 @@ module.exports = class XMLDTDNotation
# `parent` the parent `XMLDocType` element
# `name` the name of the notation
# `value` an object with external entity details
- # `value.pubid` public identifier
- # `value.sysid` system identifier
+ # `value.pubID` public identifier
+ # `value.sysID` system identifier
constructor: (parent, name, value) ->
@stringify = parent.stringify
if not name?
throw new Error "Missing notation name"
- if not value.pubid and not value.sysid
+ if not value.pubID and not value.sysID
throw new Error "Public or system identifiers are required for an external entity"
@name = @stringify.eleName name
- @pubid = @stringify.dtdPubID value.pubid if value.pubid?
- @sysid = @stringify.dtdSysID value.sysid if value.sysid?
+ @pubID = @stringify.dtdPubID value.pubID if value.pubID?
+ @sysID = @stringify.dtdSysID value.sysID if value.sysID?
# Converts the XML fragment to string
#
@@ -41,12 +41,12 @@ module.exports = class XMLDTDNotation
r += space if pretty
r += '<!NOTATION ' + @name
- if @pubid and @sysid
- r += ' PUBLIC "' + @pubid + '" "' + @sysid + '"'
- else if @pubid
- r += ' PUBLIC "' + @pubid + '"'
- else if @sysid
- r += ' SYSTEM "' + @sysid + '"'
+ if @pubID and @sysID
+ r += ' PUBLIC "' + @pubID + '" "' + @sysID + '"'
+ else if @pubID
+ r += ' PUBLIC "' + @pubID + '"'
+ else if @sysID
+ r += ' SYSTEM "' + @sysID + '"'
r += '>'
r += newline if pretty
View
@@ -54,9 +54,9 @@ module.exports = class XMLDocType
#
# `name` the name of the entity
# `value` internal entity value or an object with external entity details
- # `value.pubid` public identifier
- # `value.sysid` system identifier
- # `value.ndata` notation declaration
+ # `value.pubID` public identifier
+ # `value.sysID` system identifier
+ # `value.nData` notation declaration
entity: (name, value) ->
XMLDTDEntity = require './XMLDTDEntity'
child = new XMLDTDEntity @, false, name, value
@@ -68,8 +68,8 @@ module.exports = class XMLDocType
#
# `name` the name of the entity
# `value` internal entity value or an object with external entity details
- # `value.pubid` public identifier
- # `value.sysid` system identifier
+ # `value.pubID` public identifier
+ # `value.sysID` system identifier
pEntity: (name, value) ->
XMLDTDEntity = require './XMLDTDEntity'
child = new XMLDTDEntity @, true, name, value
@@ -81,8 +81,8 @@ module.exports = class XMLDocType
#
# `name` the name of the notation
# `value` an object with external entity details
- # `value.pubid` public identifier
- # `value.sysid` system identifier
+ # `value.pubID` public identifier
+ # `value.sysID` system identifier
notation: (name, value) ->
XMLDTDNotation = require './XMLDTDNotation'
child = new XMLDTDNotation @, name, value
@@ -184,4 +184,4 @@ module.exports = class XMLDocType
com: (value) -> @comment value
ins: (target, value) -> @instruction target, value
up: () -> @root()
- doc: () -> @document()
+ doc: () -> @document()
View
@@ -28,17 +28,6 @@ vows
'<root><node>test</node></root>'
assert.strictEqual topic.end(), xml
- 'SYSTEM dtd from create() with legacy ext attribute':
- topic: () ->
- xmlbuilder.create('root', { ext: 'hello.dtd' })
- .ele('node').txt('test')
-
- 'resulting XML': (topic) ->
- xml = '<?xml version="1.0"?>' +
- '<!DOCTYPE root SYSTEM "hello.dtd">' +
- '<root><node>test</node></root>'
- assert.strictEqual topic.end(), xml
-
'Internal and external dtd':
topic: () ->
xmlbuilder.create('root')
@@ -48,19 +37,19 @@ vows
.com('Image attributes follow')
.att('img', 'height', 'CDATA', '#REQUIRED')
.att('img', 'visible', '(yes|no)', '#DEFAULT', "yes")
- .not('fs', { sysid: 'http://my.fs.com/reader' })
- .not('fs-nt', { pubid: 'FS Network Reader 1.0', sysid: 'http://my.fs.com/reader' })
+ .not('fs', { sysID: 'http://my.fs.com/reader' })
+ .not('fs-nt', { pubID: 'FS Network Reader 1.0', sysID: 'http://my.fs.com/reader' })
.att('img', 'src', 'NOTATION (fs|fs-nt)', '#REQUIRED')
.dat('<owner>John</owner>')
.ele('node')
.ent('ent', 'my val')
- .ent('ent', { sysid: 'http://www.myspec.com/ent' })
- .ent('ent', { pubid: '-//MY//SPEC ENT//EN', sysid: 'http://www.myspec.com/ent' })
- .ent('ent', { sysid: 'http://www.myspec.com/ent', ndata: 'entprg' })
- .ent('ent', { pubid: '-//MY//SPEC ENT//EN', sysid: 'http://www.myspec.com/ent', ndata: 'entprg' })
+ .ent('ent', { sysID: 'http://www.myspec.com/ent' })
+ .ent('ent', { pubID: '-//MY//SPEC ENT//EN', sysID: 'http://www.myspec.com/ent' })
+ .ent('ent', { sysID: 'http://www.myspec.com/ent', nData: 'entprg' })
+ .ent('ent', { pubID: '-//MY//SPEC ENT//EN', sysID: 'http://www.myspec.com/ent', nData: 'entprg' })
.pent('ent', 'my val')
- .pent('ent', { sysid: 'http://www.myspec.com/ent' })
- .pent('ent', { pubid: '-//MY//SPEC ENT//EN', sysid: 'http://www.myspec.com/ent' })
+ .pent('ent', { sysID: 'http://www.myspec.com/ent' })
+ .pent('ent', { pubID: '-//MY//SPEC ENT//EN', sysID: 'http://www.myspec.com/ent' })
.root()
.ele('node').txt('test')

0 comments on commit 5a4f323

Please sign in to comment.