Exemple #1
0
	/**
	 * Determine the fully qualified URI for a string.
	 *
	 * @param urlString string to qualify
	 * @return string to fully qualified URI
	 */
	static void
	getURLStringFromString(
			const XalanDOMString&	urlString,
			XalanDOMString&			theNormalizedURI)
	{
		getURLStringFromString(urlString.c_str(), urlString.length(), theNormalizedURI);
	}
    static const DOMStringType
    XalanDOMStringToXercesDOMString(const XalanDOMString&   theString)
    {
        assert(XercesStringLengthType(theString.length()) == theString.length());

        return DOMStringType(&theString[0], XercesStringLengthType(theString.length()));
    }
Exemple #3
0
	/**
	 * Determine the fully qualified URI for a string.
	 *
	 * @param urlString string to qualify
	 * @param base base location for URI
	 * @param theNormalizedURI fully qualified URI
	 */
	static void
	getURLStringFromString(
			const XalanDOMString&	urlString,
			const XalanDOMString&	base,
			XalanDOMString&			theNormalizedURI)
	{
		getURLStringFromString(urlString.c_str(), base.c_str(), theNormalizedURI);
	}
Exemple #4
0
XSLTInputSource::XSLTInputSource(
            const XalanDOMString&   systemId,
            const XalanDOMString&   publicId,
            MemoryManager&          theMemoryManager) :
    InputSource(
        systemId.c_str(),
        publicId.c_str(),
        &theMemoryManager),
    m_stream(0),
    m_node(0)
{
}
Exemple #5
0
TranscodeToLocalCodePage(
            const XalanDOMString&   theSourceString,
            CharVectorType&         theTargetVector,
            bool                    terminate,
            char                    theSubstitutionChar)
{
    doTranscodeToLocalCodePage(
        theSourceString.c_str(),
        theSourceString.length(),
        true,
        theTargetVector,
        terminate,
        theSubstitutionChar);
}
XalanOutputStream::UnsupportedEncodingException::UnsupportedEncodingException(
            const XalanDOMString&   theEncoding,
            XalanDOMString&         theBuffer) :
    XalanOutputStreamException(
        XalanMessageLoader::getMessage(
            theBuffer,
            XalanMessages::UnsupportedEncoding_1Param,
            theEncoding),
        theBuffer.getMemoryManager()),
   m_encoding(
       theEncoding, 
       theBuffer.getMemoryManager())
{
}
XalanOutputStream::TranscoderInternalFailureException::TranscoderInternalFailureException(
            const XalanDOMString&   theEncoding,
            XalanDOMString&         theBuffer) :
    XalanOutputStreamException(
        XalanMessageLoader::getMessage(
            theBuffer, 
            XalanMessages::UnknownErrorOccurredWhileTranscodingToEncoding_1Param,
            theEncoding),
        theBuffer.getMemoryManager()),
    m_encoding(
        theEncoding,
        theBuffer.getMemoryManager())
{
}
Exemple #8
0
void
XUnknown::str(
            XPathExecutionContext&  /* executionContext */,
            XalanDOMString&         theBuffer) const
{
    theBuffer.append(m_value);
}
void
XTokenNumberAdapter::str(
            XPathExecutionContext&  /* executionContext */,
            XalanDOMString&         theBuffer) const
{
    theBuffer.append(m_value.str());
}
Exemple #10
0
 /**
  * Static conversion function. Appends the supplied boolean
  * value to a string.
  *
  * @param theBool The boolean value to convert.
  * @param theString The string value of the provided boolean value.
  */
 static void
 string(
         bool                theBool,
         XalanDOMString&     theString)
 {
     theString.append(theBool == true ? s_trueString : s_falseString);
 }
Exemple #11
0
TranscodeFromLocalCodePage(
            const CharVectorType&   theSourceString,
            XalanDOMString&         result)
{
    if (theSourceString.empty() == true)
    {
        result.erase();

        return result;
    }
    else
    {
        typedef XalanDOMString::size_type       size_type;

        const CharVectorType::size_type     theSize = theSourceString.size();

        if (theSourceString[theSize - 1] == CharVectorType::value_type(0))
        {
            return TranscodeFromLocalCodePage(&*theSourceString.begin(), result , size_type(theSize) - 1);
        }
        else
        {
            return TranscodeFromLocalCodePage(&*theSourceString.begin(), result , size_type(theSize));
        }
    }
}
Exemple #12
0
	virtual bool
	isActive(const XalanDOMString&	thePrefix) const
	{
		bool	fActive = false;

		for(unsigned int i = 0; i < m_avtsCount; ++i)
		{
			const AVT* const	avt = m_avts[i];

			const XalanDOMString&	theName = avt->getName();

			const XalanDOMString::size_type		theColonIndex = indexOf(theName, XalanUnicode::charColon);

			if (theColonIndex != length(theName))
			{
				if (thePrefix.length() == theColonIndex &&
					startsWith(theName, thePrefix) == true)
				{
					fActive = true;

					break;
				}
			}
		}

		return fActive;
	}
void
XalanXMLSerializerFactory::setEncoding(
                             MemoryManager&          theManager,
                             Writer&            theWriter,
                             XalanDOMString&    theEncoding)
{
    XalanOutputStream* stream = theWriter.getStream();

    if(stream != 0)
    {
        if(theEncoding.empty())
        {
            // Default to UTF-8 if the requested encoding is not supported...
            stream->setOutputEncoding(XalanDOMString(XalanTranscodingServices::s_utf8String, theManager));

            theEncoding = XalanTranscodingServices::s_utf8String;
        }
        else
        {
            try
            {
                stream->setOutputEncoding(theEncoding);
            }
            catch(const XalanOutputStream::UnsupportedEncodingException&)
            {
                // Default to UTF-8 if the requested encoding is not supported...
                stream->setOutputEncoding(XalanDOMString(XalanTranscodingServices::s_utf8String, theManager));

                theEncoding = XalanTranscodingServices::s_utf8String;
            }
        }

    }
}
Exemple #14
0
	/**
	 * Determine the fully qualified URI for a string.
	 *
	 * @param urlString string to qualify
	 * @param url to update with the qualified string.
	 */
	static void
	getURLFromString(
			const XalanDOMString&	urlString,
			XMLURLType&				url,
            MemoryManagerType&      theManager)
	{
		getURLFromString(urlString.c_str(), url, theManager);
	}
Exemple #15
0
bool
XalanDOMString::equals(
            const XalanDOMString&   theLHS,
            const XalanDOMString&   theRHS)
{
    const XalanDOMString::size_type     theLHSLength = theLHS.size();
    const XalanDOMString::size_type     theRHSLength = theRHS.size();

    if (theLHSLength != theRHSLength)
    {
        return false;
    }
    else
    {
        return equals(theLHS.c_str(), theLHSLength, theRHS.c_str(), theRHSLength);
    }
}
XalanOutputStream::TranscodingException::TranscodingException(XalanDOMString&   theBuffer) :
    XalanOutputStreamException(
        XalanMessageLoader::getMessage(
            theBuffer,
            XalanMessages::AnErrorOccurredWhileTranscoding),
        theBuffer.getMemoryManager())
{
}
XALAN_CPP_NAMESPACE_BEGIN



DOMStringPrintWriter::DOMStringPrintWriter(XalanDOMString&	theString) :
PrintWriter(true, theString.getMemoryManager()),
	m_outputString(&theString)
{
}
Exemple #18
0
void
AVTPartSimple::evaluate(
            XalanDOMString&         buf,
            const PrefixResolver&   /* prefixResolver */,
            XPathExecutionContext&  /* executionContext */) const

{
    buf.append(m_val, m_len);
}
Exemple #19
0
    /**
     * Calls the supplied FormatterListener member function with
     * the string.
     *
     * @param theString The XalanDOMString to convert.
     * @param formatterListener The FormatterListener instance.
     * @param function The FormatterListener member function to call.
     */
    static void
    string(
            const XalanDOMString&   theString,
            FormatterListener&      formatterListener,
            MemberFunctionPtr       function)
    {
        const XalanDOMString::size_type     theLength =
            theString.length();

        if (theLength != 0)
        {
            assert(theLength == static_cast<FormatterListener::size_type>(theLength));

            (formatterListener.*function)(
                theString.c_str(),
                static_cast<FormatterListener::size_type>(theLength));
        }
    }
Exemple #20
0
inline void
reset_func(XalanDOMString& obj, MemoryManager&    theManager, Type string)
{
    assert( string != 0 );

    XalanDOMString tmpString(string, theManager);

    obj.swap(tmpString);
}
Exemple #21
0
XalanDOMString::XalanDOMString(
            const XalanDOMString&   theSource,
            MemoryManager&      theManager,
            size_type               theStartPosition,
            size_type               theCount) :
    m_data(theManager),
    m_size(0)
{
    if (theSource.length() != 0)
    {
        append(theSource, theStartPosition, theCount);
    }
}
XObjectPtr
FunctionSample::execute(
            XPathExecutionContext&  executionContext,
            XalanNode*              /* context */,          
            const XObjectPtr        arg1,
            const XObjectPtr        arg2,
            const Locator*          /* locator */) const
{
   assert(arg1.null() == false);
   assert(arg2.null() == false);

   XalanDOMString path;
   arg1->str(path);
   const bool bLinux = arg2->boolean();

   XalanDOMChar dchOld;
   XalanDOMChar dchNew;

   if (bLinux)
   {
      dchOld = '\\';
      dchNew = '/';
   }
   else
   {
      dchOld = '/';
      dchOld = '\\';
   }

    int len = path.length();
   for (int i=0; i<len; i++)
      if (path[i] == dchOld)
         path[i] = dchNew;

    return executionContext.getXObjectFactory().createString(path); 
}
Exemple #23
0
	/**
	 * Append the value to the buffer.
	 *
	 * @param buf              buffer to write into
	 * @param prefixResolver   prefix resolver to use
	 * @param executionContext execution context
	 */
	void
	evaluate(
			XalanDOMString&			buf,
			const PrefixResolver&	prefixResolver,
			XPathExecutionContext&	executionContext) const
	{
		if(m_simpleString != 0)
		{
			buf.assign(m_simpleString, m_simpleStringLength);
		}
		else
		{
			doEvaluate(buf, prefixResolver, executionContext);
		}
	}
XalanFileOutputStream::XalanFileOutputStreamWriteException::XalanFileOutputStreamWriteException(
        const XalanDOMString&   theFileName,
        int                     theErrorCode,
        XalanDOMString&         theBuffer,
        const Locator*          theLocator) :
    XalanOutputStreamException(
        formatMessage(
            XalanMessageLoader::getMessage(
                theBuffer,
                XalanMessages::ErrorWritingFile_1Param,
                theFileName),
            theErrorCode,
            theBuffer),
        theBuffer.getMemoryManager(),
        theLocator)
{
}
Exemple #25
0
void
ExtensionNSHandler::setElements(const XalanDOMString&   elemNames)
{
    if (elemNames.empty() == false)
    {
        StringTokenizer     st(elemNames, s_tokenDelimiterCharacters, false);

        XalanDOMString theResult(m_elements.getMemoryManager());

        while (st.hasMoreTokens() == true)
        {
            st.nextToken(theResult);

            m_elements.insert(theResult); // just stick it in there basically
        }
    
        m_componentDescLoaded = true;
    }
}
Exemple #26
0
void SocketOutputStream::write(const XalanDOMString& s, XalanDOMString::size_type offset,
        XalanDOMString::size_type length)
{
    //printf(stderr,"write(DOMString='%s',offset=%d,length=%s", s.c_str(), offset, length);
    m_socket->write((const char*)(s.c_str()+offset), length*sizeof(XalanDOMChar));
}
void
XTokenNumberAdapter::str(XalanDOMString&    theBuffer) const
{
    theBuffer.append(m_value.str());
}
Exemple #28
0
void TXFMXPath::evaluateExpr(DOMNode *h, safeBuffer inexpr) {

	// Temporarily add any necessary name spaces into the document

	XSECXPathNodeList addedNodes;
	setXPathNS(document, XPathAtts, addedNodes, formatter, mp_nse);

	XPathProcessorImpl	xppi;					// The processor
	XercesParserLiaison xpl;
#if XALAN_VERSION_MAJOR == 1 && XALAN_VERSION_MINOR > 10
	XercesDOMSupport	xds(xpl);
#else
	XercesDOMSupport	xds;
#endif
	XPathEvaluator		xpe;
	XPathFactoryDefault xpf;
	XPathConstructionContextDefault xpcc;

	XalanDocument		* xd;
	XalanNode			* contextNode;

	// Xalan can throw exceptions in all functions, so do one broad catch point.

	try {
	
		// Map to Xalan
		xd = xpl.createDocument(document);

		// For performing mapping
		XercesDocumentWrapper *xdw = xpl.mapDocumentToWrapper(xd);
		XercesWrapperNavigator xwn(xdw);

		// Map the "here" node - but only if part of current document

		XalanNode * hereNode = NULL;

		if (h->getOwnerDocument() == document) {
			
			hereNode = xwn.mapNode(h);

			if (hereNode == NULL) {

				hereNode = findHereNodeFromXalan(&xwn, xd, h);

				if (hereNode == NULL) {

					throw XSECException(XSECException::XPathError,
					   "Unable to find here node in Xalan Wrapper map");
				}

			}
		}

		// Now work out what we have to set up in the new processing

		TXFMBase::nodeType inputType = input->getNodeType();

		XalanDOMString cd;		// For the moment assume the root is the context

		const XalanDOMChar * cexpr;

		safeBuffer contextExpr;

		switch (inputType) {

		case DOM_NODE_DOCUMENT :
		case DOM_NODE_XPATH_NODESET :
			// do XPath over the whole document and, if the input was an 
			// XPath Nodeset, then later intersect the result with the input nodelist			
			cd = XalanDOMString("/");		// Root node
			cexpr = cd.c_str();

			// The context node is the "root" node
			contextNode =
				xpe.selectSingleNode(
				xds,
				xd,
				cexpr,
				xd->getDocumentElement());

			break;

		case DOM_NODE_DOCUMENT_FRAGMENT :
			{

				// Need to map the DOM_Node that we are given from the input to the appropriate XalanNode

				// Create the XPath expression to find the node

				if (input->getFragmentId() != NULL) {

					contextExpr.sbTranscodeIn("//descendant-or-self::node()[attribute::Id='");
					contextExpr.sbXMLChCat(input->getFragmentId());
					contextExpr.sbXMLChCat("']");

					// Map the node

					contextNode = 
						xpe.selectSingleNode(
						xds,
						xd,
						contextExpr.rawXMLChBuffer(), //XalanDOMString((char *) contextExpr.rawBuffer()).c_str(), 
						xd->getDocumentElement());


					if (contextNode == NULL) {
						// Last Ditch
						contextNode = xwn.mapNode(input->getFragmentNode());

					}

				}
				else
					contextNode = xwn.mapNode(input->getFragmentNode());

				if (contextNode == NULL) {

					// Something wrong
					throw XSECException(XSECException::XPathError, "Error mapping context node");

				}

				break;
			}

		default :

			throw XSECException(XSECException::XPathError);	// Should never get here

		}

		safeBuffer str;
		XPathEnvSupportDefault xpesd;
		XObjectFactoryDefault			xof;
		XPathExecutionContextDefault	xpec(xpesd, xds, xof);

		ElementPrefixResolverProxy pr(xd->getDocumentElement(), xpesd, xds);

		// Work around the fact that the XPath implementation is designed for XSLT, so does
		// not allow here() as a NCName.

		// THIS IS A KLUDGE AND SHOULD BE DONE BETTER

		int offset = 0;
		safeBuffer k(KLUDGE_PREFIX);
		k.sbStrcatIn(":");

		offset = inexpr.sbStrstr("here()");

		while (offset >= 0) {

			if (offset == 0 || offset == 1 || 
				(!(inexpr[offset - 1] == ':' && inexpr[offset - 2] != ':') &&
				separator(inexpr[offset - 1]))) {

				inexpr.sbStrinsIn(k.rawCharBuffer(), offset);

			}

			offset = inexpr.sbOffsetStrstr("here()", offset + 11);

		}

		// Install the External function in the Environment handler

		if (hereNode != NULL) {

			xpesd.installExternalFunctionLocal(XalanDOMString(URI_ID_DSIG), XalanDOMString("here"), DSIGXPathHere(hereNode));

		}

		str.sbStrcpyIn("(descendant-or-self::node() | descendant-or-self::node()/attribute::* | descendant-or-self::node()/namespace::*)[");
		str.sbStrcatIn(inexpr);
		str.sbStrcatIn("]");

		XPath * xp = xpf.create();

		XalanDOMString Xexpr((char *) str.rawBuffer());
		xppi.initXPath(*xp, xpcc, Xexpr, pr);
		
		// Now resolve

		XObjectPtr xObj = xp->execute(contextNode, pr, xpec);

		// Now map to a list that others can use (naieve list at this time)

		const NodeRefListBase&	lst = xObj->nodeset();
		
		int size = (int) lst.getLength();
		const DOMNode *item;
		
		for (int i = 0; i < size; ++ i) {

			if (lst.item(i) == xd)
				m_XPathMap.addNode(document);
			else {
				item = xwn.mapNode(lst.item(i));
				m_XPathMap.addNode(item);
			}
		}

		if (inputType == DOM_NODE_XPATH_NODESET) {
			//the input list was a XPATH nodeset, so we must intersect the 
			// results of the XPath processing done above with the input nodeset
			m_XPathMap.intersect(input->getXPathNodeList());
		}
	}

	catch (XSLException &e) {

		safeBuffer msg;

		// Whatever happens - fix any changes to the original document
		clearXPathNS(document, addedNodes, formatter, mp_nse);
	
		// Collate the exception message into an XSEC message.		
		msg.sbTranscodeIn("Xalan Exception : ");
#if defined (XSEC_XSLEXCEPTION_RETURNS_DOMSTRING)
		msg.sbXMLChCat(e.getType().c_str());
#else
		msg.sbXMLChCat(e.getType());
#endif
		msg.sbXMLChCat(" caught.  Message : ");
		msg.sbXMLChCat(e.getMessage().c_str());

		throw XSECException(XSECException::XPathError,
			msg.rawXMLChBuffer());
	}
	
	clearXPathNS(document, addedNodes, formatter, mp_nse);

}
Exemple #29
0
 /**
  * Static conversion function.  Returns the boolean value
  * of the supplied XalanDOMString.
  *
  * @param theString The XalanDOMString to convert.
  * @return bool value
  */
 static bool
 boolean(const XalanDOMString&   theString)
 {
     return theString.length() == 0 ? false : true;
 }
 void
 write(const XalanDOMString&     theChars)
 {
     write(theChars.c_str(), theChars.length());
 }