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

Class: XML_GRDDL_Driver

Source Location: /XML_GRDDL-0.2.0/XML/GRDDL/Driver.php

Class Overview


An abstract driver for GRDDL


Author(s):

Version:

  • Release: @package_version@

Variables

Methods


Child classes:

XML_GRDDL_Driver_Xsl
A driver for PHP 5's XSL extension.

Inherited Variables

Inherited Methods


Class Details

[line 66]
An abstract driver for GRDDL

Provides public methods to fetch documents, discover transformations, execute transformations and merge resulting documents.



[ Top ]


Class Variables

$logger =

[line 79]

A logging class - an instance of PEAR::Log
  • Access: protected

Type:   mixed


[ Top ]

$options =

[line 74]

A set of options for the driver

Type:   mixed


[ Top ]

$urlCache = array()

[line 84]

A set of urls which have already been fetched
  • Access: protected

Type:   mixed


[ Top ]



Method Detail

__construct (Constructor)   [line 96]

void __construct( [mixed[] $options = array()])

Make a new instance of XML_GRRDL_Driver directly

Overridden in child classes as:

XML_GRDDL_Driver_Xsl::__construct()
Make a new instance of XML_GRRDL_Driver_XSL directly

Parameters:

mixed[]   $options   —  An array of driver specific options

[ Top ]

appendProfiles   [line 790]

string appendProfiles( string $xhtml, [string[] $profiles = array()])

Append one or more profiles to a HTML document.
  • Access: public

Parameters:

string   $xhtml   —  Raw XHTML to parse and manipulate
string[]   $profiles   —  Profile urls to insert

[ Top ]

crawl   [line 737]

string crawl( string $url)

Fetch, inspect, parse and merge a URL.

If you just want to get RDF, and you want to get it now...

  • Return: Resulting RDF document
  • Access: public

Parameters:

string   $url   —  Address of document to crawl.

[ Top ]

determineBaseURI   [line 404]

string determineBaseURI( SimpleXMLElement $sxe, string $originalUrl)

Inspect a DOMDocument and kludge together a base URI.

Otherwise, try to use the existing original document location.

  • Access: protected

Parameters:

SimpleXMLElement   $sxe   —  A SimpleXMLElement to inspect
string   $originalUrl   —  Where the DOMDocument originally lived

[ Top ]

discoverDocumentTransformations   [line 451]

string[] discoverDocumentTransformations( SimpleXMLElement $sxe, [string $originalUrl = null])

Given an XPath[XPATH] root node N with root element E, if the expression

*[local-name()="transformation" and namespace-uri()= "http://www.w3.org/2003/g/data-view#"]

matches an attribute of an element E, then for each space-separated token REF in the value of that attribute, the resource identified[WEBARCH] by the absolute form (see section 5.2 Relative Resolution in [RFC3986]) of REF with respect to the base IRI[RFC3987],[XMLBASE] of E is a GRDDL transformation of N.

Space-separated tokens are the maximal non-empty subsequences not containing the whitespace characters #x9, #xA, #xD or #x20.

  • Return: A list of transformations, as urls
  • Access: protected

Parameters:

SimpleXMLElement   $sxe   —  Prepopulated document to inspect for transformations.
string   $originalUrl   —  The original url this document lived at.

[ Top ]

discoverHTMLProfileTransformations   [line 297]

string[] discoverHTMLProfileTransformations( SimpleXMLElement $sxe, [string $originalUrl = null])

Look for profileTransformations (via PROFILE tags).
  • Return: A list of transformations, as urls
  • Todo: Determine if I need to make //xhtml:head[@profile] behave like a namespace transformation (I think I might?)
  • Todo: Determine if I need to make //xhtml:head[@profile] softer for HTML 4
  • Access: protected

Parameters:

SimpleXMLElement   $sxe   —  Prepopulated document to inspect for transformations, found by $xpath
string   $originalUrl   —  Original url this document lived at

[ Top ]

discoverHTMLTransformations   [line 271]

string[] discoverHTMLTransformations( SimpleXMLElement $sxe, [string $originalUrl = null])

Look for transformations hidden in A, LINK tag.
  • Return: An array of XSL transformation urls.
  • Access: protected

Parameters:

SimpleXMLElement   $sxe   —  Prepopulated document to inspect for transformations, found by $xpath
string   $originalUrl   —  Original url this document lived at

[ Top ]

discoverNamespaceTransformations   [line 475]

string[] discoverNamespaceTransformations( SimpleXMLElement $sxe)

Transformations can be associated not only with individual documents but also with whole dialects that share an XML namespace.

Any resource available for retrieval from a namespace URI is a namespace document (cf. section 4.5.4. Namespace documents in [WEBARCH]). For example, a namespace document may have an XML Schema representation or an RDF Schema representation, or perhaps both, using content negotiation.

To associate a GRDDL transformation with a whole dialect, include a grddl:namespaceTransformation property in a GRDDL result of the namespace document.

  • Return: A list of transformations, as urls
  • Access: protected

Parameters:

SimpleXMLElement   $sxe   —  Prepopulated document to inspect for namespaces.

[ Top ]

discoverTransformations   [line 232]

string[] discoverTransformations( SimpleXMLElement $sxe, string $originalUrl, string $xpath, string $attributeName, [string $namespace = null])

Discover transformations in the provided document by using the xpath provided.
  • Return: A list of transformations, as urls
  • Access: protected

Parameters:

SimpleXMLElement   $sxe   —  Prepopulated document to inspect for transformations, found by $xpath
string   $originalUrl   —  Original url this document lived at
string   $xpath   —  XPath expression to evaluate
string   $attributeName   —  The node attribute to read
string   $namespace   —  The namespace of the attribute, if applicable

[ Top ]

fetch   [line 534]

string fetch( string $path, [string $preferredExtension = 'html'])

Fetch a URL, specifically asking for XML or RDF where available.
  • Return: Contents of $path
  • Todo: Remove ugly preferredExtension hackery.
  • Throws: XML_GRDDL_Exception Unable to fetch url or file
  • Access: public

Parameters:

string   $path   —  Path to fetch - typically URL.
string   $preferredExtension   —  Preferred default extension

[ Top ]

findRedirect   [line 764]

string findRedirect( string $url)

If this URL has been fetched before, return its resolved location (after all redirects)
  • Access: protected

Parameters:

string   $url   —  URL

[ Top ]

inspect   [line 158]

string[] inspect( string $xml, [string $originalUrl = null])

Inspect raw XML for transformations, according to options
  • Return: An array of transformations (urls)
  • Access: public

Parameters:

string   $xml   —  String of XML to inspect
string   $originalUrl   —  Where this document used to live

[ Top ]

isURI   [line 499]

bool isURI( string $string)

Inspect a string to see if it is a valid URL
  • Access: public

Parameters:

string   $string   —  Input to check

[ Top ]

knownNamespaceTransformations   [line 361]

string[] knownNamespaceTransformations( string $nsUrl)

Fetch a URL, which should be a namespace document of some description.

Look for namespaceTransformations

  • Return: An array of transformation urls described in $nsUrl
  • Todo: Logging
  • Todo: Check a cache of some description
  • Access: protected

Parameters:

string   $nsUrl   —  Namespace URL

[ Top ]

logRedirect   [line 777]

string logRedirect( string $url, string $otherUrl)

Record a redirection for a url
  • Access: protected

Parameters:

string   $url   —  URL
string   $otherUrl   —  Redirected URL

[ Top ]

merge   [line 696]

string merge( string $graphXml1, string $graphXml2)

Merge two GRDDL results into one.

If F and G are GRDDL results of IR, then the merge [RDF-MT] of F and G is also a GRDDL result of IR.

?IR grddl:result ?F, ?G. (?F ?G) log:conjunction ?H.

?IR grddl:result ?H.


Parameters:

string   $graphXml1   —  An RDF/XML graph
string   $graphXml2   —  A second RDF/XML graph, to be merged into the first.

[ Top ]

prettify   [line 629]

string prettify( string $xml, [string $originalUrl = null])

Prettify XML.

Obeys options for preserveWhiteSpace & formatOutput, and removes redundant namespaces


Parameters:

string   $xml   —  XML to format
string   $originalUrl   —  Original document URL

[ Top ]

transform   [line 516]

string transform( string $stylesheet, string $xml)

Transform the given XML with the provided XSLT.

Driver implementations should override this method.

  • Return: Transformed document contents.
  • Abstract:
  • Access: public

Overridden in child classes as:

XML_GRDDL_Driver_Xsl::transform()
Transform the given XML with the provided XSLT.

Parameters:

string   $stylesheet   —  URL or file location of an XSLT transformation
string   $xml   —  String of XML

[ Top ]


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