Back to index

lightning-sunbird  0.9+nobinonly
Classes | Defines | Functions
txStandaloneStylesheetCompiler.cpp File Reference
#include "txStandaloneStylesheetCompiler.h"
#include "TxLog.h"
#include "txStylesheetCompiler.h"
#include "txURIUtils.h"
#include "expat_config.h"
#include "expat.h"

Go to the source code of this file.

Classes

class  txDriver
 Implementation of an In-Memory DOM based XML parser. More...

Defines

#define TX_DRIVER(_userData)   NS_STATIC_CAST(txDriver*, _userData)
 expat C stub handlers

Functions

nsresult TX_CompileStylesheetPath (const txParsedURL &aURL, txStylesheet **aResult)
 API to load XML files into compiled stylesheets.
 startElement (void *aUserData, const XML_Char *aName, const XML_Char **aAtts)
 endElement (void *aUserData, const XML_Char *aName)
 charData (void *aUserData, const XML_Char *aChars, int aLength)
 externalEntityRefHandler (XML_Parser aParser, const XML_Char *aContext, const XML_Char *aBase, const XML_Char *aSystemId, const XML_Char *aPublicId)

Define Documentation

#define TX_DRIVER (   _userData)    NS_STATIC_CAST(txDriver*, _userData)

expat C stub handlers

Definition at line 119 of file txStandaloneStylesheetCompiler.cpp.


Function Documentation

charData ( void aUserData,
const XML_Char aChars,
int  aLength 
)

Definition at line 142 of file txStandaloneStylesheetCompiler.cpp.

{
    if (!aUserData) {
        NS_WARNING("no userData in charData handler");
        return;
    }
    TX_DRIVER(aUserData)->CharacterData(aChars, aLength);
}

Here is the caller graph for this function:

endElement ( void aUserData,
const XML_Char aName 
)

Definition at line 132 of file txStandaloneStylesheetCompiler.cpp.

{
    if (!aUserData) {
        NS_WARNING("no userData in endElement handler");
        return;
    }
    TX_DRIVER(aUserData)->EndElement(aName);
}

Here is the caller graph for this function:

externalEntityRefHandler ( XML_Parser  aParser,
const XML_Char aContext,
const XML_Char aBase,
const XML_Char aSystemId,
const XML_Char aPublicId 
)

Definition at line 152 of file txStandaloneStylesheetCompiler.cpp.

{
    // aParser is aUserData is the txDriver,
    // we set that in txDriver::parse
    NS_ENSURE_TRUE(aParser, XML_ERROR_NONE);
    return ((txDriver*)aParser)->ExternalEntityRef(aContext, aBase,
                                                   aSystemId, aPublicId);
}

Here is the caller graph for this function:

startElement ( void aUserData,
const XML_Char aName,
const XML_Char **  aAtts 
)

Definition at line 122 of file txStandaloneStylesheetCompiler.cpp.

{
    if (!aUserData) {
        NS_WARNING("no userData in startElement handler");
        return;
    }
    TX_DRIVER(aUserData)->StartElement(aName, aAtts);
}

Here is the caller graph for this function:

nsresult TX_CompileStylesheetPath ( const txParsedURL &  aURL,
txStylesheet **  aResult 
)

API to load XML files into compiled stylesheets.

Parsing is done by expat. Parse a stylesheet from the aPath.

Definition at line 79 of file txStandaloneStylesheetCompiler.cpp.

{
    *aResult = nsnull;
    nsAutoString errMsg, filePath;

    aURL.getFile(filePath);
    PR_LOG(txLog::xslt, PR_LOG_ALWAYS,
           ("TX_CompileStylesheetPath: %s\n",
            NS_LossyConvertUCS2toASCII(filePath).get()));
    istream* xslInput = URIUtils::getInputStream(filePath, errMsg);
    if (!xslInput) {
        return NS_ERROR_FAILURE;
    }
    nsRefPtr<txDriver> driver = new txDriver();
    if (!driver) {
        return NS_ERROR_OUT_OF_MEMORY;
    }
    nsAutoString spec = filePath;
    if (!aURL.mRef.IsEmpty()) {
        spec.Append(PRUnichar('#'));
        spec.Append(aURL.mRef);
    }
    driver->mCompiler =  new txStylesheetCompiler(spec, driver);
    if (!driver->mCompiler) {
        return NS_ERROR_OUT_OF_MEMORY;
    }
    nsresult rv = driver->parse(*xslInput, filePath);
    if (NS_FAILED(rv)) {
        return rv;
    };
    *aResult = driver->mCompiler->getStylesheet();
    NS_ADDREF(*aResult);
    return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function: