Back to index

lightning-sunbird  0.9+nobinonly
Public Member Functions | Public Attributes | Private Member Functions | Private Attributes
txMozillaXSLTProcessor Class Reference

txMozillaXSLTProcessor is a front-end to the XSLT Processor. More...

#include <txMozillaXSLTProcessor.h>

Inheritance diagram for txMozillaXSLTProcessor:
Inheritance graph
[legend]
Collaboration diagram for txMozillaXSLTProcessor:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 txMozillaXSLTProcessor ()
 Creates a new txMozillaXSLTProcessor.
virtual ~txMozillaXSLTProcessor ()
 Default destructor for txMozillaXSLTProcessor.
NS_DECL_ISUPPORTS
NS_DECL_NSIXSLTPROCESSOR
NS_DECL_NSIXSLTPROCESSOROBSOLETE
NS_DECL_NSIXSLTPROCESSORPRIVATE
NS_IMETHOD 
SetTransformObserver (nsITransformObserver *aObserver)
NS_IMETHOD LoadStyleSheet (nsIURI *aUri, nsILoadGroup *aLoadGroup, nsIPrincipal *aCallerPrincipal)
NS_IMETHOD SetSourceContentModel (nsIDOMNode *aSource)
NS_IMETHOD CancelLoads ()
NS_IMETHOD AddXSLTParamNamespace (const nsString &aPrefix, const nsString &aNamespace)
NS_IMETHOD AddXSLTParam (const nsString &aName, const nsString &aNamespace, const nsString &aSelect, const nsString &aValue, nsIDOMNode *aContext)
NS_DECL_NSIDOCUMENTOBSERVER
nsresult 
setStylesheet (txStylesheet *aStylesheet)
void reportError (nsresult aResult, const PRUnichar *aErrorText, const PRUnichar *aSourceText)
nsIDOMNodeGetSourceContentModel ()
nsresult TransformToDoc (nsIDOMDocument *aOutputDoc, nsIDOMDocument **aResult)
PRBool IsLoadDisabled ()
void importStylesheet (in nsIDOMNode style)
 Import the stylesheet into this XSLTProcessor for transformations.
nsIDOMDocumentFragment transformToFragment (in nsIDOMNode source, in nsIDOMDocument output)
 Transforms the node source applying the stylesheet given by the importStylesheet() function.
nsIDOMDocument transformToDocument (in nsIDOMNode source)
 Transforms the node source applying the stylesheet given by the importStylesheet() function.
void setParameter (in DOMString namespaceURI, in DOMString localName, in nsIVariant value)
 Sets a parameter to be used in subsequent transformations with this nsIXSLTProcessor.
nsIVariant getParameter (in DOMString namespaceURI, in DOMString localName)
 Gets a parameter if previously set by setParameter.
void removeParameter (in DOMString namespaceURI, in DOMString localName)
 Removes a parameter, if set.
void clearParameters ()
 Removes all set parameters from this nsIXSLTProcessor.
void reset ()
 Remove all parameters and stylesheets from this nsIXSLTProcessor.
void transformDocument (in nsIDOMNode aSourceDOM, in nsIDOMNode aStyleDOM, in nsIDOMDocument aOutputDOC, in nsISupports aObserver)
virtual void BeginUpdate (nsIDocument *aDocument, nsUpdateType aUpdateType)=0
 Notify that a content model update is beginning.
virtual void EndUpdate (nsIDocument *aDocument, nsUpdateType aUpdateType)=0
 Notify that a content model update is finished.
virtual void BeginLoad (nsIDocument *aDocument)=0
 Notify the observer that a document load is beginning.
virtual void EndLoad (nsIDocument *aDocument)=0
 Notify the observer that a document load has finished.
virtual void BeginReflow (nsIDocument *aDocument, nsIPresShell *aShell)=0
 Notify the observer that the document is being reflowed in the given presentation shell.
virtual void EndReflow (nsIDocument *aDocument, nsIPresShell *aShell)=0
 Notify the observer that the document is done being reflowed in the given presentation shell.
virtual void CharacterDataChanged (nsIDocument *aDocument, nsIContent *aContent, PRBool aAppend)=0
 Notification that the content model has changed.
virtual void ContentStatesChanged (nsIDocument *aDocument, nsIContent *aContent1, nsIContent *aContent2, PRInt32 aStateMask)=0
 Notification that the state of a content node has changed.
virtual void AttributeChanged (nsIDocument *aDocument, nsIContent *aContent, PRInt32 aNameSpaceID, nsIAtom *aAttribute, PRInt32 aModType)=0
 Notification that the content model has changed.
virtual void ContentAppended (nsIDocument *aDocument, nsIContent *aContainer, PRInt32 aNewIndexInContainer)=0
 Notifcation that the content model has had data appended to the given content object.
virtual void ContentInserted (nsIDocument *aDocument, nsIContent *aContainer, nsIContent *aChild, PRInt32 aIndexInContainer)=0
 Notification that content has been inserted.
virtual void ContentRemoved (nsIDocument *aDocument, nsIContent *aContainer, nsIContent *aChild, PRInt32 aIndexInContainer)=0
 Content has just been removed.
virtual void StyleSheetAdded (nsIDocument *aDocument, nsIStyleSheet *aStyleSheet, PRBool aDocumentSheet)=0
 A StyleSheet has just been added to the document.
virtual void StyleSheetRemoved (nsIDocument *aDocument, nsIStyleSheet *aStyleSheet, PRBool aDocumentSheet)=0
 A StyleSheet has just been removed from the document.
virtual void StyleSheetApplicableStateChanged (nsIDocument *aDocument, nsIStyleSheet *aStyleSheet, PRBool aApplicable)=0
 A StyleSheet has just changed its applicable state.
virtual void StyleRuleChanged (nsIDocument *aDocument, nsIStyleSheet *aStyleSheet, nsIStyleRule *aOldStyleRule, nsIStyleRule *aNewStyleRule)=0
 A StyleRule has just been modified within a style sheet.
virtual void StyleRuleAdded (nsIDocument *aDocument, nsIStyleSheet *aStyleSheet, nsIStyleRule *aStyleRule)=0
 A StyleRule has just been added to a style sheet.
virtual void StyleRuleRemoved (nsIDocument *aDocument, nsIStyleSheet *aStyleSheet, nsIStyleRule *aStyleRule)=0
 A StyleRule has just been removed from a style sheet.
virtual void DocumentWillBeDestroyed (nsIDocument *aDocument)=0
 The document is in the process of being destroyed.

Public Attributes

const unsigned long DISABLE_ALL_LOADS = 1
 Disables all loading of external documents, such as from <xsl:import> and document() Defaults to off and is not reset by calls to reset()
attribute unsigned long flags
 Flags for this processor.

Private Member Functions

nsresult DoTransform ()
void notifyError ()
nsresult ensureStylesheet ()

Private Attributes

nsRefPtr< txStylesheetmStylesheet
nsIDocumentmStylesheetDocument
nsCOMPtr< nsIContentmEmbeddedStylesheetRoot
nsCOMPtr< nsIDOMNodemSource
nsresult mTransformResult
nsresult mCompileResult
nsString mErrorText
nsString mSourceText
nsCOMPtr< nsITransformObservermObserver
txExpandedNameMap mVariables
txNamespaceMap mParamNamespaceMap
nsRefPtr< txResultRecyclermRecycler
PRUint32 mFlags

Detailed Description

txMozillaXSLTProcessor is a front-end to the XSLT Processor.

Definition at line 127 of file txMozillaXSLTProcessor.h.


Constructor & Destructor Documentation

Default destructor for txMozillaXSLTProcessor.

Definition at line 269 of file txMozillaXSLTProcessor.cpp.

Here is the call graph for this function:


Member Function Documentation

NS_IMETHODIMP txMozillaXSLTProcessor::AddXSLTParam ( const nsString aName,
const nsString aNamespace,
const nsString aSelect,
const nsString aValue,
nsIDOMNode aContext 
) [virtual]

Implements nsIDocumentTransformer_1_8_BRANCH.

Definition at line 417 of file txMozillaXSLTProcessor.cpp.

{
    nsresult rv = NS_OK;

    if (aSelect.IsVoid() == aValue.IsVoid()) {
        // Ignore if neither or both are specified
        return NS_ERROR_FAILURE;
    }

    nsRefPtr<txAExprResult> value;
    if (!aSelect.IsVoid()) {

        // Set up context
        nsAutoPtr<txXPathNode> contextNode(
          txXPathNativeNode::createXPathNode(aContext));
        NS_ENSURE_TRUE(contextNode, NS_ERROR_OUT_OF_MEMORY);

        if (!mRecycler) {
            mRecycler = new txResultRecycler;
            NS_ENSURE_TRUE(mRecycler, NS_ERROR_OUT_OF_MEMORY);

            rv = mRecycler->init();
            NS_ENSURE_SUCCESS(rv, rv);
        }

        txXSLTParamContext paramContext(&mParamNamespaceMap, *contextNode,
                                        mRecycler);

        // Parse
        nsAutoPtr<Expr> expr;
        rv = txExprParser::createExpr(aSelect, &paramContext,
                                      getter_Transfers(expr));
        NS_ENSURE_SUCCESS(rv, rv);

        // Evaluate
        rv = expr->evaluate(&paramContext, getter_AddRefs(value));
        NS_ENSURE_SUCCESS(rv, rv);
    }
    else {
        value = new StringResult(aValue, nsnull);
        NS_ENSURE_TRUE(value, NS_ERROR_OUT_OF_MEMORY);
    }

    nsCOMPtr<nsIAtom> name = do_GetAtom(aName);
    PRInt32 nsId = txNamespaceManager::getNamespaceID(aNamespace);
    NS_ENSURE_FALSE(nsId == kNameSpaceID_Unknown, NS_ERROR_FAILURE);

    txExpandedName varName(nsId, name);
    txVariable* var = (txVariable*)mVariables.get(varName);
    if (var) {
        var->setValue(value);
        
        return NS_OK;
    }

    var = new txVariable(value);
    NS_ENSURE_TRUE(var, NS_ERROR_OUT_OF_MEMORY);

    return mVariables.add(varName, var);
}

Here is the call graph for this function:

Implements nsIDocumentTransformer_1_8_BRANCH.

Definition at line 333 of file txMozillaXSLTProcessor.cpp.

{
    nsCOMPtr<nsIAtom> pre = do_GetAtom(aPrefix);
    return mParamNamespaceMap.mapNamespace(pre, aNamespace);
}

Here is the call graph for this function:

virtual void nsIDocumentObserver::AttributeChanged ( nsIDocument aDocument,
nsIContent aContent,
PRInt32  aNameSpaceID,
nsIAtom aAttribute,
PRInt32  aModType 
) [pure virtual, inherited]

Notification that the content model has changed.

This method is called automatically by content objects when an attribute's value has changed (therefore there is normally no need to invoke this method directly). The notification is passed to any IDocumentObservers document observers.

Parameters:
aDocumentThe document being observed
aContentthe piece of content whose attribute changed
aAttributethe atom name of the attribute
aModTypeWhether or not the attribute was added, changed, or removed. The constants are defined in nsIDOMMutationEvent.h.

Implemented in PresShell, nsContentList, nsXULContentBuilder, nsXULTemplateBuilder, nsImageMap, nsTreeContentView, and nsXMLPrettyPrinter.

virtual void nsIDocumentObserver::BeginLoad ( nsIDocument aDocument) [pure virtual, inherited]

Notify the observer that a document load is beginning.

Implemented in PresShell.

virtual void nsIDocumentObserver::BeginReflow ( nsIDocument aDocument,
nsIPresShell aShell 
) [pure virtual, inherited]

Notify the observer that the document is being reflowed in the given presentation shell.

virtual void nsIDocumentObserver::BeginUpdate ( nsIDocument aDocument,
nsUpdateType  aUpdateType 
) [pure virtual, inherited]

Notify that a content model update is beginning.

This call can be nested.

Implemented in nsFragmentObserver, PresShell, HTMLContentSink, and nsXMLPrettyPrinter.

Implements nsIDocumentTransformer.

Definition at line 162 of file txMozillaXSLTProcessor.h.

{return NS_OK;};
virtual void nsIDocumentObserver::CharacterDataChanged ( nsIDocument aDocument,
nsIContent aContent,
PRBool  aAppend 
) [pure virtual, inherited]

Notification that the content model has changed.

This method is called automatically by content objects when their state is changed (therefore there is normally no need to invoke this method directly). The notification is passed to any IDocumentObservers. The notification is passed on to all of the document observers.

This notification is not sent when a piece of content is added/removed from the document (the other notifications are used for that).

Parameters:
aDocumentThe document being observed
aContentthe piece of content that changed
aAppendWhether the change was an append

Implemented in PresShell.

Removes all set parameters from this nsIXSLTProcessor.

This will make the processor use the default-value for all parameters as specified in the stylesheet.

virtual void nsIDocumentObserver::ContentAppended ( nsIDocument aDocument,
nsIContent aContainer,
PRInt32  aNewIndexInContainer 
) [pure virtual, inherited]

Notifcation that the content model has had data appended to the given content object.

This method is called automatically by the content container objects when a new content object is appended to the container (therefore there is normally no need to invoke this method directly). The notification is passed on to all of the document observers.

Parameters:
aDocumentThe document being observed
aContainerthe container that had a new child appended
aNewIndexInContainerthe index in the container of the first new child

Implemented in PresShell, nsContentList, nsBindingManager, nsImageMap, nsTreeContentView, and nsXMLPrettyPrinter.

virtual void nsIDocumentObserver::ContentInserted ( nsIDocument aDocument,
nsIContent aContainer,
nsIContent aChild,
PRInt32  aIndexInContainer 
) [pure virtual, inherited]

Notification that content has been inserted.

This method is called automatically by the content container objects when a new content object is inserted in the container (therefore there is normally no need to invoke this method directly). The notification is passed on to all of the document observers.

Parameters:
aDocumentThe document being observed
aContainerthe container that now contains aChild
aChildthe child that was inserted
aIndexInContainerthe index of the child in the container

Implemented in PresShell, nsContentList, nsBindingManager, nsImageMap, nsTreeContentView, and nsXMLPrettyPrinter.

virtual void nsIDocumentObserver::ContentRemoved ( nsIDocument aDocument,
nsIContent aContainer,
nsIContent aChild,
PRInt32  aIndexInContainer 
) [pure virtual, inherited]

Content has just been removed.

This method is called automatically by content container objects when a content object has just been removed from the container (therefore there is normally no need to invoke this method directly). The notification is passed on to all of the document observers.

Parameters:
aDocumentThe document being observed
aContainerthe container that had a child removed
aChildthe child that was just removed
aIndexInContainerthe index of the child in the container before it was removed

Implemented in PresShell, nsContentList, nsBindingManager, nsImageMap, nsTreeContentView, and nsXMLPrettyPrinter.

virtual void nsIDocumentObserver::ContentStatesChanged ( nsIDocument aDocument,
nsIContent aContent1,
nsIContent aContent2,
PRInt32  aStateMask 
) [pure virtual, inherited]

Notification that the state of a content node has changed.

(ie: gained or lost focus, became active or hovered over) This method is called automatically by content objects when their state is changed (therefore there is normally no need to invoke this method directly). The notification is passed to any IDocumentObservers. The notification is passed on to all of the document observers.

This notification is not sent when a piece of content is added/removed from the document or the content itself changed (the other notifications are used for that).

The optional second content node is to allow optimization of the case where state moves from one node to another (as is likely for :focus and :hover)

Either content node may be nsnull, but not both

Parameters:
aDocumentThe document being observed
aContent1the piece of content that changed
aContent2optional second piece of content that changed

Implemented in PresShell, and nsTreeContentView.

virtual void nsIDocumentObserver::DocumentWillBeDestroyed ( nsIDocument aDocument) [pure virtual, inherited]

The document is in the process of being destroyed.

This method is called automatically during document destruction.

Parameters:
aDocumentThe document being observed

Implemented in nsFragmentObserver, nsDOMStyleSheetList, nsContentList, nsBindingManager, nsXULContentBuilder, nsXULTreeBuilder, nsXULTemplateBuilder, nsTreeContentView, and nsXMLPrettyPrinter.

Definition at line 508 of file txMozillaXSLTProcessor.cpp.

{
    NS_ENSURE_TRUE(mSource, NS_ERROR_UNEXPECTED);
    NS_ENSURE_TRUE(mStylesheet, NS_ERROR_UNEXPECTED);
    NS_ASSERTION(mObserver, "no observer");

    nsresult rv;
    nsCOMPtr<nsIDocument> document = do_QueryInterface(mSource, &rv);
    NS_ENSURE_SUCCESS(rv, rv);

    nsCOMPtr<nsIEventQueueService> service =
        do_GetService(NS_EVENTQUEUESERVICE_CONTRACTID, &rv);
    NS_ENSURE_SUCCESS(rv, rv);
    nsCOMPtr<nsIEventQueue> eventQ;
    rv = service->GetSpecialEventQueue(nsIEventQueueService::UI_THREAD_EVENT_QUEUE,
                                       getter_AddRefs(eventQ));
    NS_ENSURE_SUCCESS(rv, rv);

    PLEvent* event = new PLEvent();
    if (!event) {
        return NS_ERROR_OUT_OF_MEMORY;
    }

    PL_InitEvent(event, this, HandleTransformBlockerEvent,
                 DestroyTransformBlockerEvent);

    document->BlockOnload();

    // After this point, event destruction will release |this| (in
    // DestroyTransformBlockerEvent)
    NS_ADDREF_THIS();

    rv = eventQ->PostEvent(event);
    if (NS_FAILED(rv)) {
        // XXX Maybe we should just display the source document in this case?
        //     Also, set up context information, see bug 204655.
        reportError(rv, nsnull, nsnull);
        PL_DestroyEvent(event);
    }

    return rv;
}

Here is the call graph for this function:

Here is the caller graph for this function:

virtual void nsIDocumentObserver::EndLoad ( nsIDocument aDocument) [pure virtual, inherited]

Notify the observer that a document load has finished.

Note that the associated reflow of the document will be done before EndLoad is invoked, not after.

Implemented in PresShell.

virtual void nsIDocumentObserver::EndReflow ( nsIDocument aDocument,
nsIPresShell aShell 
) [pure virtual, inherited]

Notify the observer that the document is done being reflowed in the given presentation shell.

virtual void nsIDocumentObserver::EndUpdate ( nsIDocument aDocument,
nsUpdateType  aUpdateType 
) [pure virtual, inherited]

Notify that a content model update is finished.

This call can be nested.

Implemented in PresShell, HTMLContentSink, and nsXMLPrettyPrinter.

nsIVariant nsIXSLTProcessor::getParameter ( in DOMString  namespaceURI,
in DOMString  localName 
) [inherited]

Gets a parameter if previously set by setParameter.

Returns null otherwise.

Parameters:
namespaceURIThe namespaceURI of the XSLT parameter
localNameThe local name of the XSLT parameter
Returns:
nsIVariant The value of the XSLT parameter

Definition at line 178 of file txMozillaXSLTProcessor.h.

    {
        return mSource;
    }

Here is the caller graph for this function:

Import the stylesheet into this XSLTProcessor for transformations.

Parameters:
styleThe root-node of a XSLT stylesheet. This can be either a document node or an element node. If a document node then the document can contain either a XSLT stylesheet or a LRE stylesheet. If the argument is an element node it must be the xsl:stylesheet (or xsl:transform) element of an XSLT stylesheet.
Exceptions:
nsIXSLTException

Definition at line 186 of file txMozillaXSLTProcessor.h.

    {
        return (mFlags & DISABLE_ALL_LOADS) != 0;
    }

Here is the caller graph for this function:

NS_IMETHODIMP txMozillaXSLTProcessor::LoadStyleSheet ( nsIURI aUri,
nsILoadGroup aLoadGroup,
nsIPrincipal aCallerPrincipal 
) [virtual]

Implements nsIDocumentTransformer.

Definition at line 995 of file txMozillaXSLTProcessor.cpp.

{
    nsresult rv = TX_LoadSheet(aUri, this, aLoadGroup, aCallerPrincipal);
    if (NS_FAILED(rv) && mObserver) {
        // This is most likely a network or security error, just
        // use the uri as context.
        nsCAutoString spec;
        if (aUri) {
            aUri->GetSpec(spec);
            CopyUTF8toUTF16(spec, mSourceText);
        }
        reportError(rv, nsnull, nsnull);
    }
    return rv;
}

Here is the call graph for this function:

Definition at line 1075 of file txMozillaXSLTProcessor.cpp.

{
    nsresult rv;
    nsCOMPtr<nsIDOMDocument> errorDocument = do_CreateInstance(kXMLDocumentCID,
                                                               &rv);
    if (NS_FAILED(rv)) {
        return;
    }

    // Set up the document
    nsCOMPtr<nsIDocument> document = do_QueryInterface(errorDocument);
    if (!document) {
        return;
    }
    URIUtils::ResetWithSource(document, mSource);

    NS_NAMED_LITERAL_STRING(ns, "http://www.mozilla.org/newlayout/xml/parsererror.xml");

    nsCOMPtr<nsIDOMElement> element;
    rv = errorDocument->CreateElementNS(ns, NS_LITERAL_STRING("parsererror"),
                                        getter_AddRefs(element));
    if (NS_FAILED(rv)) {
        return;
    }

    nsCOMPtr<nsIContent> rootContent = do_QueryInterface(element);
    if (!rootContent) {
        return;
    }

    rv = document->SetRootContent(rootContent);
    if (NS_FAILED(rv)) {
        return;
    }

    nsCOMPtr<nsIDOMText> text;
    rv = errorDocument->CreateTextNode(mErrorText, getter_AddRefs(text));
    if (NS_FAILED(rv)) {
        return;
    }

    nsCOMPtr<nsIDOMNode> resultNode;
    rv = element->AppendChild(text, getter_AddRefs(resultNode));
    if (NS_FAILED(rv)) {
        return;
    }

    if (!mSourceText.IsEmpty()) {
        nsCOMPtr<nsIDOMElement> sourceElement;
        rv = errorDocument->CreateElementNS(ns,
                                            NS_LITERAL_STRING("sourcetext"),
                                            getter_AddRefs(sourceElement));
        if (NS_FAILED(rv)) {
            return;
        }
    
        rv = element->AppendChild(sourceElement, getter_AddRefs(resultNode));
        if (NS_FAILED(rv)) {
            return;
        }

        rv = errorDocument->CreateTextNode(mSourceText, getter_AddRefs(text));
        if (NS_FAILED(rv)) {
            return;
        }
    
        rv = sourceElement->AppendChild(text, getter_AddRefs(resultNode));
        if (NS_FAILED(rv)) {
            return;
        }
    }

    mObserver->OnTransformDone(mTransformResult, errorDocument);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void nsIXSLTProcessor::removeParameter ( in DOMString  namespaceURI,
in DOMString  localName 
) [inherited]

Removes a parameter, if set.

This will make the processor use the default-value for the parameter as specified in the stylesheet.

Parameters:
namespaceURIThe namespaceURI of the XSLT parameter
localNameThe local name of the XSLT parameter
void txMozillaXSLTProcessor::reportError ( nsresult  aResult,
const PRUnichar aErrorText,
const PRUnichar aSourceText 
)

Definition at line 1023 of file txMozillaXSLTProcessor.cpp.

{
    if (!mObserver) {
        return;
    }

    mTransformResult = aResult;

    if (aErrorText) {
        mErrorText.Assign(aErrorText);
    }
    else {
        nsCOMPtr<nsIStringBundleService> sbs =
            do_GetService(NS_STRINGBUNDLE_CONTRACTID);
        if (sbs) {
            nsXPIDLString errorText;
            sbs->FormatStatusMessage(aResult, EmptyString().get(),
                                     getter_Copies(errorText));

            nsXPIDLString errorMessage;
            nsCOMPtr<nsIStringBundle> bundle;
            sbs->CreateBundle(XSLT_MSGS_URL, getter_AddRefs(bundle));

            if (bundle) {
                const PRUnichar* error[] = { errorText.get() };
                if (mStylesheet) {
                    bundle->FormatStringFromName(NS_LITERAL_STRING("TransformError").get(),
                                                 error, 1,
                                                 getter_Copies(errorMessage));
                }
                else {
                    bundle->FormatStringFromName(NS_LITERAL_STRING("LoadingError").get(),
                                                 error, 1,
                                                 getter_Copies(errorMessage));
                }
            }
            mErrorText.Assign(errorMessage);
        }
    }

    if (aSourceText) {
        mSourceText.Assign(aSourceText);
    }

    if (mSource) {
        notifyError();
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void nsIXSLTProcessor::reset ( ) [inherited]

Remove all parameters and stylesheets from this nsIXSLTProcessor.

void nsIXSLTProcessor::setParameter ( in DOMString  namespaceURI,
in DOMString  localName,
in nsIVariant  value 
) [inherited]

Sets a parameter to be used in subsequent transformations with this nsIXSLTProcessor.

If the parameter doesn't exist in the stylesheet the parameter will be ignored.

Parameters:
namespaceURIThe namespaceURI of the XSLT parameter
localNameThe local name of the XSLT parameter
valueThe new value of the XSLT parameter
Exceptions:
NS_ERROR_ILLEGAL_VALUEThe datatype of value is not supported

Implements nsIDocumentTransformer.

Definition at line 316 of file txMozillaXSLTProcessor.cpp.

{
    mSource = aSourceDOM;

    if (NS_FAILED(mTransformResult)) {
        notifyError();
        return NS_OK;
    }

    if (mStylesheet) {
        return DoTransform();
    }

    return NS_OK;
}

Here is the call graph for this function:

Definition at line 1013 of file txMozillaXSLTProcessor.cpp.

{
    mStylesheet = aStylesheet;
    if (mSource) {
        return DoTransform();
    }
    return NS_OK;
}

Here is the call graph for this function:

Implements nsIDocumentTransformer.

Definition at line 309 of file txMozillaXSLTProcessor.cpp.

{
    mObserver = aObserver;
    return NS_OK;
}
virtual void nsIDocumentObserver::StyleRuleAdded ( nsIDocument aDocument,
nsIStyleSheet aStyleSheet,
nsIStyleRule aStyleRule 
) [pure virtual, inherited]

A StyleRule has just been added to a style sheet.

This method is called automatically when the rule gets added to the sheet. The style sheet passes this notification to the document. The notification is passed on to all of the document observers.

Parameters:
aDocumentThe document being observed
aStyleSheetthe StyleSheet that has been modified
aStyleRulethe rule that was added

Implemented in PresShell.

virtual void nsIDocumentObserver::StyleRuleChanged ( nsIDocument aDocument,
nsIStyleSheet aStyleSheet,
nsIStyleRule aOldStyleRule,
nsIStyleRule aNewStyleRule 
) [pure virtual, inherited]

A StyleRule has just been modified within a style sheet.

This method is called automatically when the rule gets modified. The style sheet passes this notification to the document. The notification is passed on to all of the document observers.

Since nsIStyleRule objects are immutable, there is a new object replacing the old one. However, the use of this method (rather than StyleRuleAdded and StyleRuleRemoved) implies that the new rule matches the same elements and has the same priority (weight, origin, specificity) as the old one. (However, if it is a CSS style rule, there may be a change in whether it has an important rule.)

Parameters:
aDocumentThe document being observed
aStyleSheetthe StyleSheet that contians the rule
aOldStyleRuleThe rule being removed. This rule may not be fully valid anymore -- however, it can still be used for pointer comparison and |QueryInterface|.
aNewStyleRuleThe rule being added.

Implemented in PresShell.

virtual void nsIDocumentObserver::StyleRuleRemoved ( nsIDocument aDocument,
nsIStyleSheet aStyleSheet,
nsIStyleRule aStyleRule 
) [pure virtual, inherited]

A StyleRule has just been removed from a style sheet.

This method is called automatically when the rule gets removed from the sheet. The style sheet passes this notification to the document. The notification is passed on to all of the document observers.

Parameters:
aDocumentThe document being observed
aStyleSheetthe StyleSheet that has been modified
aStyleRulethe rule that was removed

Implemented in PresShell.

virtual void nsIDocumentObserver::StyleSheetAdded ( nsIDocument aDocument,
nsIStyleSheet aStyleSheet,
PRBool  aDocumentSheet 
) [pure virtual, inherited]

A StyleSheet has just been added to the document.

This method is called automatically when a StyleSheet gets added to the document, even if the stylesheet is not applicable. The notification is passed on to all of the document observers.

Parameters:
aDocumentThe document being observed
aStyleSheetthe StyleSheet that has been added
aDocumentSheetTrue if sheet is in document's style sheet list, false if sheet is not (i.e., UA or user sheet)

Implemented in PresShell, and nsDOMStyleSheetList.

virtual void nsIDocumentObserver::StyleSheetApplicableStateChanged ( nsIDocument aDocument,
nsIStyleSheet aStyleSheet,
PRBool  aApplicable 
) [pure virtual, inherited]

A StyleSheet has just changed its applicable state.

This method is called automatically when the applicable state of a StyleSheet gets changed. The style sheet passes this notification to the document. The notification is passed on to all of the document observers.

Parameters:
aDocumentThe document being observed
aStyleSheetthe StyleSheet that has changed state
aApplicablePR_TRUE if the sheet is applicable, PR_FALSE if it is not applicable

Implemented in PresShell.

virtual void nsIDocumentObserver::StyleSheetRemoved ( nsIDocument aDocument,
nsIStyleSheet aStyleSheet,
PRBool  aDocumentSheet 
) [pure virtual, inherited]

A StyleSheet has just been removed from the document.

This method is called automatically when a StyleSheet gets removed from the document, even if the stylesheet is not applicable. The notification is passed on to all of the document observers.

Parameters:
aDocumentThe document being observed
aStyleSheetthe StyleSheet that has been removed
aDocumentSheetTrue if sheet is in document's style sheet list, false if sheet is not (i.e., UA or user sheet)

Implemented in PresShell, and nsDOMStyleSheetList.

void nsIXSLTProcessorObsolete::transformDocument ( in nsIDOMNode  aSourceDOM,
in nsIDOMNode  aStyleDOM,
in nsIDOMDocument  aOutputDOC,
in nsISupports  aObserver 
) [inherited]

Definition at line 615 of file txMozillaXSLTProcessor.cpp.

{
    nsAutoPtr<txXPathNode> sourceNode(txXPathNativeNode::createXPathNode(mSource));
    if (!sourceNode) {
        return NS_ERROR_OUT_OF_MEMORY;
    }

    nsCOMPtr<nsIDOMDocument> sourceDOMDocument;
    mSource->GetOwnerDocument(getter_AddRefs(sourceDOMDocument));
    if (!sourceDOMDocument) {
        sourceDOMDocument = do_QueryInterface(mSource);
    }

    txExecutionState es(mStylesheet, IsLoadDisabled());

    // XXX Need to add error observers

    txToDocHandlerFactory handlerFactory(&es, sourceDOMDocument, aOutputDoc,
                                         mObserver);
    es.mOutputHandlerFactory = &handlerFactory;

    es.init(*sourceNode, &mVariables);

    // Process root of XML source document
    nsresult rv = txXSLTProcessor::execute(es);
    es.end(rv);
    if (NS_SUCCEEDED(rv)) {
        if (aResult) {
            txAOutputXMLEventHandler* handler =
                NS_STATIC_CAST(txAOutputXMLEventHandler*, es.mOutputHandler);
            handler->getOutputDocument(aResult);
        }
    }
    else if (mObserver) {
        // XXX set up context information, bug 204655
        reportError(rv, nsnull, nsnull);
    }

    return rv;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Transforms the node source applying the stylesheet given by the importStylesheet() function.

Parameters:
sourceThe node to be transformed
Returns:
Document The result of the transformation
Exceptions:
nsIXSLTException

Transforms the node source applying the stylesheet given by the importStylesheet() function.

The owner document of the output node owns the returned document fragment.

Parameters:
sourceThe node to be transformed
outputThis document is used to generate the output
Returns:
DocumentFragment The result of the transformation
Exceptions:
nsIXSLTException

Member Data Documentation

Disables all loading of external documents, such as from <xsl:import> and document() Defaults to off and is not reset by calls to reset()

Definition at line 48 of file nsIXSLTProcessorPrivate.idl.

Flags for this processor.

Defaults to 0. See individual flags above for documentation for effect of reset()

Definition at line 54 of file nsIXSLTProcessorPrivate.idl.

Definition at line 202 of file txMozillaXSLTProcessor.h.

Definition at line 198 of file txMozillaXSLTProcessor.h.

Definition at line 203 of file txMozillaXSLTProcessor.h.

Definition at line 209 of file txMozillaXSLTProcessor.h.

Definition at line 204 of file txMozillaXSLTProcessor.h.

Definition at line 206 of file txMozillaXSLTProcessor.h.

Definition at line 207 of file txMozillaXSLTProcessor.h.

Definition at line 200 of file txMozillaXSLTProcessor.h.

Definition at line 203 of file txMozillaXSLTProcessor.h.

Definition at line 196 of file txMozillaXSLTProcessor.h.

Definition at line 197 of file txMozillaXSLTProcessor.h.

Definition at line 201 of file txMozillaXSLTProcessor.h.

Definition at line 205 of file txMozillaXSLTProcessor.h.


The documentation for this class was generated from the following files: