Back to index

lightning-sunbird  0.9+nobinonly
txXMLParser.h File Reference
#include "txCore.h"
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.


nsresult txParseDocumentFromURI (const nsAString &aHref, const txXPathNode &aLoader, nsAString &aErrMsg, txXPathNode **aResult)
 API to load XML files into DOM datastructures.

Function Documentation

nsresult txParseDocumentFromURI ( const nsAString &  aHref,
const txXPathNode aLoader,
nsAString &  aErrMsg,
txXPathNode **  aResult 

API to load XML files into DOM datastructures.

Parsing is either done by expat, or by expat via the synchloaderservice Parse a document from the aHref location, with referrer URI on behalf of the document aLoader.

Definition at line 87 of file txXMLParser.cpp.

    *aResult = nsnull;
#ifndef TX_EXE
    nsCOMPtr<nsIURI> documentURI;
    nsresult rv = NS_NewURI(getter_AddRefs(documentURI), aHref);
    NS_ENSURE_SUCCESS(rv, rv);

    nsIDocument* loaderDocument = txXPathNativeNode::getDocument(aLoader);

    nsCOMPtr<nsILoadGroup> loadGroup = loaderDocument->GetDocumentLoadGroup();
    nsIURI *loaderUri = loaderDocument->GetDocumentURI();

    nsCOMPtr<nsIChannel> channel;
    rv = NS_NewChannel(getter_AddRefs(channel), documentURI, nsnull,
    NS_ENSURE_SUCCESS(rv, rv);

    nsCOMPtr<nsIHttpChannel> http = do_QueryInterface(channel);
    if (http) {

    nsCOMPtr<nsISyncLoadDOMService> loader =
      do_GetService(";1", &rv);
    NS_ENSURE_SUCCESS(rv, rv);

    // Raw pointer, we want the resulting txXPathNode to hold a reference to
    // the document.
    nsIDOMDocument* theDocument = nsnull;
    rv = loader->LoadDocumentAsXML(channel, loaderUri, &theDocument);
    if (NS_FAILED(rv)) {
        aErrMsg.Append(NS_LITERAL_STRING("Document load of ") + 
                       aHref + NS_LITERAL_STRING(" failed."));
        return NS_FAILED(rv) ? rv : NS_ERROR_FAILURE;

    *aResult = txXPathNativeNode::createXPathNode(theDocument);
    if (!*aResult) {
        return NS_ERROR_FAILURE;

    return NS_OK;
    istream* xslInput = URIUtils::getInputStream(aHref, aErrMsg);
    if (!xslInput) {
        return NS_ERROR_FAILURE;
    return txParseFromStream(*xslInput, aHref, aErrMsg, aResult);

Here is the call graph for this function:

Here is the caller graph for this function: