CodeGen
[ class tree: CodeGen ] [ index: CodeGen ] [ all elements ]

Class: CodeGen_XmlParser

Source Location: /CodeGen-1.0.5/CodeGen/XmlParser.php

Class Overview


Yet another XML parsing class


Author(s):

Version:

  • Release: @package_version@

Copyright:

  • 2005 Hartmut Holzgraefe

Variables

Methods


Child classes:

CodeGen_ExtensionParser
Parser for XML based extension desription files

Inherited Variables

Inherited Methods


Class Details

[line 49]
Yet another XML parsing class

This is similar to the "func" mode of XML_Parser but it borrows some concepts from DSSSL. The tag handler method to call is not only determined by the tag name but also potentially by the name of its parent tags, and the most specific handler method (that is the one including the maximum number of matching parent tags in its name) wins. This way it is possible to have e.g. tagstart_name as a general handler for a <name> tag while tagstart_function_name handles the more special case of a <name> tag within a <function> tag. Character data within a tag is collected and passed to the end tag handler. Tag names and attributes are managed using stack arrays. Attributes are not only passed to both the start and end tag handlers.



[ Top ]


Class Variables

$attrStack = array()

[line 91]

We keep track of tag attributes so that we can also provide them to the end tag handlers
  • Access: protected

Type:   array


[ Top ]

$data =  ""

[line 70]

We collect cData in here
  • Access: protected

Type:   string


[ Top ]

$dataLine =  0

[line 77]

We also try to remember where cData started
  • Access: protected

Type:   int


[ Top ]

$error =  false

[line 98]

There is no clean way to terminate parsing from within a handler ...
  • Access: protected

Type:   bool


[ Top ]

$filename =  false

[line 105]

Input Filename
  • Access: protected

Type:   string


[ Top ]

$fp =  null

[line 112]

Input stream
  • Access: protected

Type:   resource


[ Top ]

$helper =  false

[line 477]

The current helper (top of stack)
  • Access: protected

Type:   mixed


[ Top ]

$helperPrev =  false

[line 484]

The previous helper (top-1 of stack)
  • Access: protected

Type:   mixed


[ Top ]

$helperStack = array()

[line 470]

A helper stack for collecting stuff
  • Access: protected

Type:   array


[ Top ]

$parser =  null

[line 56]

XML parser resource
  • Access: protected

Type:   resource


[ Top ]

$parserStack = array()

[line 63]

Parser stack for <include> management
  • Access: protected

Type:   array


[ Top ]

$tagAliases = array()

[line 132]

Tag aliases
  • Access: protected

Type:   mixed


[ Top ]

$tagStack = array()

[line 84]

We maintain the current tag nesting structure here
  • Access: protected

Type:   array


[ Top ]

$verbatim =  false

[line 119]

Verbatim indicator
  • Access: protected

Type:   string


[ Top ]

$verbatimDepth =  0

[line 126]

Verbatim taglevel depth
  • Access: protected

Type:   string


[ Top ]



Method Detail

__construct (Constructor)   [line 138]

CodeGen_XmlParser __construct( )

The constructor

Overridden in child classes as:

CodeGen_ExtensionParser::__construct()
Constructor

[ Top ]

addTagAlias   [line 614]

void addTagAlias( string $tag, string $alias)

Add a tag alias

Parameters:

string   $tag   —  Tag name
string   $alias   —  Alias for this tag

[ Top ]

cDataHandler   [line 428]

void cDataHandler( resource $XmlParser, string $data)

Just collect cData for later use in tag end handlers
  • Access: protected

Parameters:

resource   $XmlParser   —  internal parser handle
string   $data   —  cData to collect

[ Top ]

checkAttributes   [line 579]

void checkAttributes( array &$attr, array $optional, [array $required = array()])

Check attributes
  • Access: protected

Parameters:

array   &$attr   —  actual attribute/value pairs
array   $optional   —  optinal attribute names with default values
array   $required   —  required attribute names

[ Top ]

dataPiHandler   [line 460]

void dataPiHandler( resource $XmlParser, string $data)

Tread <?data PI sections like <![CDATA[
  • Access: protected

Parameters:

resource   $XmlParser   —  internal parser handle
string   $data   —  cData to collect

[ Top ]

endHandler   [line 381]

void endHandler( resource $XmlParser, string $fulltag)

Try to find a tagend handler for this tag and call it
  • Access: protected

Parameters:

resource   $XmlParser   —  internal parser handle
string   $fulltag   —  tag name

[ Top ]

extEntityHandler   [line 208]

void extEntityHandler( $parser, $openEntityNames, $base, $systemId, $publicId)

Create a new SAX parser to parse an external entity reference
  • Access: protected

Parameters:

   $parser   — 
   $openEntityNames   — 
   $base   — 
   $systemId   — 
   $publicId   — 

[ Top ]

findHandler   [line 282]

string findHandler( string $prefix)

Try to find best matching tag handler for current tag nesting
  • Return: hndler method name or false if no handler found
  • Access: protected

Parameters:

string   $prefix   —  handler method prefix

[ Top ]

newParser   [line 148]

void newParser( )

Create a new SAX parser and associate it with this XmlParser instance
  • Access: protected

[ Top ]

noAttributes   [line 563]

void noAttributes( $attr)

Check that no attributes are given
  • Access: protected

Parameters:

   $attr   — 

[ Top ]

parse   [line 241]

boolean parse( )

Perform the actual parsing
  • Return: true on success
  • Access: public

[ Top ]

piHandler   [line 443]

void piHandler( resource $XmlParser, string $name, string $data)

Delegate processing instructions
  • Access: protected

Parameters:

resource   $XmlParser   —  internal parser handle
string   $name   —  PI name
string   $data   —  PI content data

[ Top ]

popHelper   [line 503]

void popHelper( )

Pop something from the helper stack
  • Access: protected

[ Top ]

popParser   [line 183]

void popParser( )

Replace current SAX parser with one popped from the parser stack

[ Top ]

posString   [line 195]

string posString( )

Generate current parse position as string for error messages
  • Access: protected

[ Top ]

pushHelper   [line 491]

void pushHelper( mixed $helper)

Push something on the helper stack
  • Access: protected

Parameters:

mixed   $helper   — 

[ Top ]

pushParser   [line 170]

void pushParser( )

Push current SAX parser instance to the parser stack
  • Access: protected

[ Top ]

setInputFile   [line 227]

void setInputFile( string $filename)

Set file to parse
  • Access: public

Parameters:

string   $filename   — 

[ Top ]

startHandler   [line 302]

void startHandler( resource $XmlParser, string $fulltag, array $attr)

Try to find a tagstart handler for this tag and call it
  • Access: protected

Parameters:

resource   $XmlParser   —  internal parser handle
string   $fulltag   —  tag name
array   $attr   —  tag attributes

[ Top ]

toBool   [line 528]

bool toBool( mixed $arg, [string $name = ""])

Convert various boolean value representation
  • Access: protected

Parameters:

mixed   $arg   —  value
string   $name   —  optional attribute name string for error messages

[ Top ]

verbatim   [line 270]

void verbatim( )

Start verbatim mode
  • Access: protected

[ Top ]


Documentation generated on Mon, 11 Mar 2019 15:17:05 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.