示例#1
0
XalanOutputTranscoder*
XalanTranscodingServices::makeNewTranscoder(
			const XalanDOMString&	theEncodingName,
			eCode&					theResult,
			size_type				theBlockSize)
{
	XALAN_USING_XERCES(XMLPlatformUtils)

	assert(XMLPlatformUtils::fgTransService != 0);

	XalanOutputTranscoder*	theTranscoder = 0;

	XMLTransService::Codes	theCode = XMLTransService::Ok;

	if (encodingIsUTF16(theEncodingName) == true)
	{
		theResult = OK;

		theTranscoder = new XalanUTF16Transcoder;
	}
	else
	{
		XALAN_USING_XERCES(XMLTranscoder)

		XMLTranscoder*	theXercesTranscoder = 
			XMLPlatformUtils::fgTransService->makeNewTranscoderFor(
					c_wstr(theEncodingName),
					theCode,
// A glitch in Xerces 2.3 omits the default parameter, so
// we have to provide one.
#if XERCES_VERSION_MAJOR == 2 && XERCES_VERSION_MINOR == 3
					theBlockSize,
					XMLPlatformUtils::fgMemoryManager);
#else
					theBlockSize);
#endif

		theResult = translateCode(theCode);
		assert(theResult == XalanTranscodingServices::OK ||
			   theXercesTranscoder == 0);

		if (theResult == XalanTranscodingServices::OK)
		{
			theTranscoder = new XalanToXercesTranscoderWrapper(*theXercesTranscoder);
		}
	}

	return theTranscoder;
}
示例#2
0
BinInputStreamType*
XSLTInputSource::makeStream() const
{
    BinInputStreamType*     theResult = 0;

    MemoryManager*  theManager = getMemoryManager();

    assert(theManager != 0 );

    if (m_stream != 0)
    {
        
        theResult = new (theManager) StdBinInputStream(*m_stream);
    }
    else if (m_node == 0)
    {
        const XalanDOMChar* const   theSystemId = getSystemId();

        if (theSystemId != 0)
        {
            XALAN_USING_XERCES(XMLURL)

            XMLURL  theURL(theManager);

            URISupport::getURLFromString(theSystemId, theURL, *theManager);

            theResult = theURL.makeNewStream();
        }
    }

    return theResult;
}
bool
XalanMessageLoader::load(
            XalanMessages::Codes    msgToLoad,
            MemoryManager&          theMemoryManager,
            XalanDOMChar*           toFill,
            unsigned int            maxChars,
            const XalanDOMChar*     repText1, 
            const XalanDOMChar*     repText2, 
            const XalanDOMChar*     repText3,
            const XalanDOMChar*     repText4) 
{
    // Call the other version to load up the message
    if (!loadMsg(msgToLoad, toFill, maxChars))
        return false;

    XALAN_USING_XERCES(XMLString)

    // And do the token replacement
    XMLString::replaceTokens(
        toFill,
        maxChars,
        repText1,
        repText2,
        repText3,
        repText4,
        &theMemoryManager);

    return true;
}
    ~FdoXslSingleton()
    {
        XALAN_USING_XERCES(XMLPlatformUtils)
        XALAN_USING_XALAN(XalanTransformer)
        XALAN_USING_XALAN(XalanDOMString)

        // Terminate Xalan.
        XalanTransformer::terminate();
    }
    FdoXslSingleton()
    {
        XALAN_USING_XERCES(XMLPlatformUtils)
        XALAN_USING_XALAN(XalanTransformer)
        XALAN_USING_XALAN(XalanDOMString)

        // Initialize Xalan.
        XalanTransformer::initialize();
    }
示例#6
0
int
main(
			int		argc,
			char*	argv[])
{
#if !defined(NDEBUG) && defined(_MSC_VER)
	_CrtSetDbgFlag(_CrtSetDbgFlag(_CRTDBG_REPORT_FLAG) | _CRTDBG_LEAK_CHECK_DF);
	_CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_FILE);
	_CrtSetReportFile(_CRT_WARN, _CRTDBG_FILE_STDERR);
#endif

	int	theResult = 0;

	try
	{
		XALAN_USING_XERCES(XMLPlatformUtils)
		XALAN_USING_XALAN(XalanTransformer)

		// Call the static initializers for xerces and xalan, and create a transformer
		//
		XMLPlatformUtils::Initialize();

		XalanTransformer::initialize();

		theResult = runTests(argc, argv);

		XalanTransformer::terminate();

		XMLPlatformUtils::Terminate();

		XalanTransformer::ICUCleanUp();
	}
	catch(...)
	{
		cerr << "Initialization failed!" << endl << endl;

		theResult = -1;
	}

	return theResult;
}
示例#7
0
inline bool
doXercesTranscode(
            const SourceType*           theSourceString,
            XalanDOMString::size_type   theSourceStringLength,
            bool                        theSourceStringIsNullTerminated,
            XalanVector<TargetType>&    theTargetVector,
            bool                        terminate)
{
    assert(
        theSourceStringIsNullTerminated == false ||
        theSourceStringLength == XalanDOMString::length(theSourceString));

    const SourceType*   theRealSourceString = theSourceString;

    XalanVector<SourceType>     theCopiedSource(theTargetVector.getMemoryManager());

    if (theSourceStringIsNullTerminated == false)
    {
        theCopiedSource.reserve(theSourceStringLength + 1);

        theCopiedSource.assign(
            theSourceString,
            theSourceString + theSourceStringLength);

        theCopiedSource.push_back(static_cast<SourceType>(0));

        theRealSourceString = &*theCopiedSource.begin();
    }

    // Initially, let's guess the the transcoded string will be the same
    // length as the source string.
    theTargetVector.resize(theSourceStringLength + 1);

    assert(theRealSourceString != 0);

    bool            fSuccess = false;

    do
    {
        XALAN_USING_XERCES(XMLString)

        fSuccess = XMLString::transcode(
                    theRealSourceString,
                    &*theTargetVector.begin(),
                    theTargetVector.size() - 1,
                    &theTargetVector.getMemoryManager());

        if (fSuccess == false)
        {
            // We're going to assume that the maximum storage for
            // a transcoded string is 4 times the source string
            // length.  This will only occur in edge cases.
            if (theTargetVector.size() >= theSourceStringLength * 4)
            {
                break;
            }
            else
            {
                theTargetVector.resize(theTargetVector.size() + 10);
            }
        }
    } while (fSuccess == false);

    if (fSuccess == false)
    {
        theTargetVector.clear();
    }
    else
    {
        while(theTargetVector.back() == static_cast<TargetType>(0))
        {
            theTargetVector.pop_back();
        }

        if (terminate == true)
        {
            theTargetVector.push_back(static_cast<TargetType>(0));
        }
    }

    return fSuccess;
}
示例#8
0
inline void
doXercesTranscode(
            const SourceType*           theSourceString,
            XalanDOMString::size_type   theSourceStringLength,
            bool                        theSourceStringIsNullTerminated,
            XalanVector<TargetType>&    theTargetVector,
            bool                        terminate,
            char                        theSubstitutionChar)
{
    assert(
        theSourceStringIsNullTerminated == false ||
        theSourceStringLength == XalanDOMString::length(theSourceString));

    const SourceType*   theRealSourceString = theSourceString;

    XalanVector<SourceType>     theCopiedSource(theTargetVector.getMemoryManager());

    if (theSourceStringIsNullTerminated == false)
    {
        theCopiedSource.reserve(theSourceStringLength + 1);

        theCopiedSource.assign(
            theSourceString,
            theSourceString + theSourceStringLength);

        theCopiedSource.push_back(static_cast<SourceType>(0));

        theRealSourceString = &*theCopiedSource.begin();
    }

    // Initially, let's guess the the transcoded string will be the same
    // length as the source string.
    theTargetVector.resize(theSourceStringLength + 1);

    assert(theRealSourceString != 0);

    bool            fSuccess = false;

    XALAN_USING_XERCES(XMLString)

    fSuccess = XMLString::transcode(
        theRealSourceString,
        &*theTargetVector.begin(),
        theTargetVector.size() - 1,
        &theTargetVector.getMemoryManager());

    if (fSuccess == false)
    {
        // Do the "manual" transcoding.  But first, clean up from the
        // previous phase
        theTargetVector.clear();

        // See if there are any unrepresentable characters for the
        // local code page.
        SourceType oneCharArray[2];

        oneCharArray[1] = SourceType(0);

        TargetType theOneTranslatedWbChar[theOneTranslatedWbCharLen]; 

        for (XalanDOMString::size_type i = 0; i < theSourceStringLength; ++i)
        {
            oneCharArray[0] = theRealSourceString[i];

            theOneTranslatedWbChar[0] = TargetType(0);

            fSuccess = XMLString::transcode(
                oneCharArray,
                theOneTranslatedWbChar,
                theOneTranslatedWbCharLen - 1,
                &theTargetVector.getMemoryManager());

            if (fSuccess == false)
            {
                theTargetVector.push_back(theSubstitutionChar);
            }
            else
            {
                XalanDOMString::size_type theRealCharLength =
                    XalanDOMString::length(theOneTranslatedWbChar);

                // When we transcode the character '\0', that looks like "\0\0", 
                // XalanDOMString::length returns a size of 0.  In this case, the
                // real size should be 1
                if (theRealCharLength == 0)
                {
                    theRealCharLength = 1;
                }

                // append the translated set of characters
                theTargetVector.insert(
                    theTargetVector.end(),
                    theOneTranslatedWbChar,
                    theOneTranslatedWbChar + theRealCharLength);
            }
        }

    }

    while(theTargetVector.back() == static_cast<TargetType>(0))
    {
        theTargetVector.pop_back();
    }

    if (terminate == true)
    {
        theTargetVector.push_back(static_cast<TargetType>(0));
    }
}