typedef nsresult NS_STDCALL_FUNCPROTO(nsIRDFContainerUtils::*nsContainerTestFn, (nsIRDFDataSource* aDataSource, nsIRDFResource* aResource, PRBool* aResult));  typedef nsresult NS_STDCALL_FUNCPROTO(nsIRDFContainerUtils::*nsMakeContainerFn, (nsIRDFDataSource* aDataSource, nsIRDFResource* aContainer, nsIRDFContainer** aResult));  typedef struct ContainerInfo { nsIRDFResource**  mType; nsContainerTestFn mTestFn; nsMakeContainerFn mMakeFn; } ContainerInfo;
MOZ_DECL_CTOR_COUNTER(RDFContentSinkImpl::NameSpaceEntry)class RDFContentSinkImpl : public nsIRDFContentSink,                           public nsIExpatSink{public:    RDFContentSinkImpl();    virtual ~RDFContentSinkImpl();    // nsISupports    NS_DECL_ISUPPORTS    NS_DECL_NSIEXPATSINK    // nsIContentSink    NS_IMETHOD WillBuildModel(void);    NS_IMETHOD DidBuildModel(PRInt32 aQualityLevel);    NS_IMETHOD WillInterrupt(void);    NS_IMETHOD WillResume(void);    NS_IMETHOD SetParser(nsIParser* aParser);      NS_IMETHOD FlushPendingNotifications() { return NS_OK; }    NS_IMETHOD SetDocumentCharset(nsAString& aCharset) { return NS_OK; }    // nsIRDFContentSink    NS_IMETHOD Init(nsIURI* aURL);    NS_IMETHOD SetDataSource(nsIRDFDataSource* aDataSource);    NS_IMETHOD GetDataSource(nsIRDFDataSource*& aDataSource);    // pseudo constants    static PRInt32 gRefCnt;    static nsIRDFService* gRDFService;    static nsIRDFContainerUtils* gRDFContainerUtils;    static nsIRDFResource* kRDF_type;    static nsIRDFResource* kRDF_instanceOf; // XXX should be RDF:type    static nsIRDFResource* kRDF_Alt;    static nsIRDFResource* kRDF_Bag;    static nsIRDFResource* kRDF_Seq;    static nsIRDFResource* kRDF_nextVal;    static nsIAtom* kAboutAtom;    static nsIAtom* kIdAtom;    static nsIAtom* kAboutEachAtom;    static nsIAtom* kResourceAtom;    static nsIAtom* kRDFAtom;    static nsIAtom* kDescriptionAtom;    static nsIAtom* kBagAtom;    static nsIAtom* kSeqAtom;    static nsIAtom* kAltAtom;    static nsIAtom* kLiAtom;    static nsIAtom* kXMLNSAtom;    static nsIAtom* kParseTypeAtom;protected:    // Text management    void ParseText(nsIRDFNode **aResult);    nsresult FlushText(PRBool aCreateTextNode=PR_TRUE,                       PRBool* aDidFlush=nsnull);    nsresult AddText(const PRUnichar* aText, PRInt32 aLength);    // RDF-specific parsing    nsresult OpenRDF(const PRUnichar* aName);    nsresult OpenObject(const PRUnichar* aName ,const PRUnichar** aAttributes);    nsresult OpenProperty(const PRUnichar* aName, const PRUnichar** aAttributes);    nsresult OpenMember(const PRUnichar* aName, const PRUnichar** aAttributes);    nsresult OpenValue(const PRUnichar* aName, const PRUnichar** aAttributes);        nsresult GetIdAboutAttribute(const PRUnichar** aAttributes, nsIRDFResource** aResource, PRBool* aIsAnonymous = nsnull);    nsresult GetResourceAttribute(const PRUnichar** aAttributes, nsIRDFResource** aResource);    nsresult AddProperties(const PRUnichar** aAttributes, nsIRDFResource* aSubject, PRInt32* aCount = nsnull);    void SetParseMode(const PRUnichar **aAttributes);    // namespace management    nsresult PushNameSpacesFrom(const PRUnichar** aAttributes);    PRBool   IsXMLNSDirective(const nsAString& aAttributeKey, nsIAtom** aPrefix = nsnull);    nsresult PopNameSpaces();    PRUnichar* mText;    PRInt32 mTextLength;    PRInt32 mTextSize;    PRBool mConstrainSize;    struct NameSpaceEntry {    public:        NameSpaceEntry(nsIAtom* aPrefix, const char* aNameSpaceURI)            : mPrefix(aPrefix), mNext(nsnull) {            MOZ_COUNT_CTOR(RDFContentSinkImpl::NameSpaceEntry);            mNameSpaceURI = PL_strdup(aNameSpaceURI);        }        ~NameSpaceEntry() {            MOZ_COUNT_DTOR(RDFContentSinkImpl::NameSpaceEntry);            PL_strfree(mNameSpaceURI);        }        nsCOMPtr<nsIAtom> mPrefix;        char*             mNameSpaceURI;        NameSpaceEntry*   mNext;    };    NameSpaceEntry* mNameSpaceStack;    nsAutoVoidArray mNameSpaceScopes;    nsIAtom*    CutNameSpacePrefix(const nsAString& aString, nsIAtom** aTagAtom);    nsresult    GetNameSpaceURI(nsIAtom* aPrefix, const char** aNameSpaceURI);    nsresult    ParseTagString(const PRUnichar* aTagName,                   const char** aNameSpaceURI,                   nsIAtom** aTag);    nsresult    ParseAttributeString(const nsAString& aAttributeName,                         const char** aNameSpaceURI,                         nsIAtom** aAttribute);    enum eContainerType { eBag, eSeq, eAlt };    nsresult InitContainer(nsIRDFResource* aContainerType, nsIRDFResource* aContainer);    nsresult ReinitContainer(nsIRDFResource* aContainerType, nsIRDFResource* aContainer);    // The datasource in which we're assigning assertions    nsCOMPtr<nsIRDFDataSource> mDataSource;    // The current state of the content sink    RDFContentSinkState mState;    RDFContentSinkParseMode mParseMode;    // content stack management    PRInt32             PushContext(nsIRDFResource *aContext,                RDFContentSinkState aState,                RDFContentSinkParseMode aParseMode);    nsresult    PopContext(nsIRDFResource         *&aContext,               RDFContentSinkState     &aState,               RDFContentSinkParseMode &aParseMode);    nsIRDFResource* GetContextElement(PRInt32 ancestor = 0);    nsAutoVoidArray* mContextStack;    nsIURI*      mDocumentURL;};