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

Class: CodeGen_XmlParser

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

Class Overview


Yet another XML parsing class


Author(s):

Version:

  • Release: @package_version@

Copyright:

  • 2005-2008 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 98]

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 105]

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

Type:   bool


[ Top ]

$filename =  false

[line 112]

Input Filename
  • Access: protected

Type:   string


[ Top ]

$fp =  null

[line 119]

Input stream
  • Access: protected

Type:   resource


[ Top ]

$helper =  false

[line 478]

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

Type:   mixed


[ Top ]

$helperPrev =  false

[line 485]

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

Type:   mixed


[ Top ]

$helperStack = array()

[line 471]

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 139]

Tag aliases
  • Access: protected

Type:   mixed


[ Top ]

$tagAliasStack = array()

[line 91]

We also need to maintain a stack for tag aliases
  • Access: protected

Type:   array


[ Top ]

$tagStack = array()

[line 84]

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

Type:   array


[ Top ]

$verbatim =  false

[line 126]

Verbatim indicator
  • Access: protected

Type:   string


[ Top ]

$verbatimDepth =  0

[line 133]

Verbatim taglevel depth
  • Access: protected

Type:   string


[ Top ]



Method Detail

__construct (Constructor)   [line 145]

CodeGen_XmlParser __construct( )

The constructor

Overridden in child classes as:

CodeGen_ExtensionParser::__construct()
Constructor

[ Top ]

addTagAlias   [line 615]

void addTagAlias( string $tag, string $alias)

Add a tag alias

Parameters:

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

[ Top ]

cDataHandler   [line 432]

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 580]

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 461]

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 384]

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 215]

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 289]

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 155]

void newParser( )

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

[ Top ]

noAttributes   [line 564]

void noAttributes( $attr)

Check that no attributes are given
  • Access: protected

Parameters:

   $attr     

[ Top ]

parse   [line 248]

boolean parse( )

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

[ Top ]

piHandler   [line 444]

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 504]

void popHelper( )

Pop something from the helper stack
  • Access: protected

[ Top ]

popParser   [line 190]

void popParser( )

Replace current SAX parser with one popped from the parser stack

[ Top ]

posString   [line 202]

string posString( )

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

[ Top ]

pushHelper   [line 492]

void pushHelper( mixed $helper)

Push something on the helper stack
  • Access: protected

Parameters:

mixed   $helper     

[ Top ]

pushParser   [line 177]

void pushParser( )

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

[ Top ]

setInputFile   [line 234]

void setInputFile( string $filename)

Set file to parse
  • Access: public

Parameters:

string   $filename     

[ Top ]

startHandler   [line 309]

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 529]

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 277]

void verbatim( )

Start verbatim mode
  • Access: protected

[ Top ]


Documentation generated on Mon, 27 Sep 2010 12:00:08 +0000 by phpDocumentor 1.4.3. PEAR Logo Copyright © PHP Group 2004.