| 334 | } |
| 335 | |
| 336 | export class XmlStringParser extends XmlProducerBase implements XmlProducer { |
| 337 | private error: ErrorFormatter; |
| 338 | |
| 339 | constructor(error?: ErrorFormatter) { |
| 340 | super(); |
| 341 | this.error = error || PositionErrorFormat; |
| 342 | } |
| 343 | |
| 344 | public parse(value: ParseInputData) { |
| 345 | if (__UI_USE_XML_PARSER__) { |
| 346 | const xmlParser = new xml.XmlParser( |
| 347 | (args: xml.ParserEvent) => { |
| 348 | try { |
| 349 | this.next(args); |
| 350 | } catch (e) { |
| 351 | throw this.error(e, args.position); |
| 352 | } |
| 353 | }, |
| 354 | (e, p) => { |
| 355 | throw this.error(e, p); |
| 356 | }, |
| 357 | true, |
| 358 | ); |
| 359 | |
| 360 | if (isString(value)) { |
| 361 | xmlParser.parse(<string>value); |
| 362 | } else if (isObject(value) && isString(value.default)) { |
| 363 | xmlParser.parse(value.default); |
| 364 | } |
| 365 | } |
| 366 | } |
| 367 | } |
| 368 | |
| 369 | interface ErrorFormatter { |
| 370 | (e: Error, p: xml.Position): Error; |
nothing calls this directly
no outgoing calls
no test coverage detected