static bool basicURLTest()
{
    static BasicTestEntry testList[] =
    {
        {
            L"file://*****:*****@host/path1/path2/file.txt?query#fragment"
            , L"file://*****:*****@host/path1/path2/file.txt?query#fragment"
            , XMLURL::File
            , 0
            , L"fragment"
            , L"host"
            , L"/path1/path2/file.txt"
            , L"password"
            , L"query"
            , L"user"
        }
      , {
            L"file:///path2/file.txt?query#fragment"
            , L"file:///path2/file.txt?query#fragment"
            , XMLURL::File
            , 0
            , L"fragment"
            , 0
            , L"/path2/file.txt"
            , 0
            , L"query"
            , 0
        }
      , {
            L"#fragment"
            , L"#fragment"
            , XMLURL::Unknown
            , 0
            , L"fragment"
            , 0
            , 0
            , 0
            , 0
            , 0
        }
      , {
            L"file://user@host/path1/path2/file.txt#fragment"
            , L"file://user@host/path1/path2/file.txt#fragment"
            , XMLURL::File
            , 0
            , L"fragment"
            , L"host"
            , L"/path1/path2/file.txt"
            , 0
            , 0
            , L"user"
        }
      , {
            L"     file://user@host/path1/path2/file.txt#fragment"
            , L"file://user@host/path1/path2/file.txt#fragment"
            , XMLURL::File
            , 0
            , L"fragment"
            , L"host"
            , L"/path1/path2/file.txt"
            , 0
            , 0
            , L"user"
        }
      , {
            L"http://*****:*****@"
            , L"ftp://user@"
            , XMLURL::FTP
            , 21
            , 0
            , 0
            , 0
            , 0
            , 0
            , L"user"
        }
    };
    const unsigned int testCount = sizeof(testList) / sizeof(testList[0]);

    bool retVal = true;

    //
    //  Do a run where we construct the URL over and over for each
    //  test.
    //
    unsigned int index;
    for (index = 0; index < testCount; index++)
    {
        // Force full destruction each time
        {
            XMLURL testURL(testList[index].orgURL);

            // Call the comparison function
            if (!checkBasicResult(testURL, testList[index]))
                retVal = false;
        }
    }

    //
    //  Do a run where we use a single URL object and just reset it over
    //  and over again.
    //
    XMLURL testURL;
    for (index = 0; index < testCount; index++)
    {
        testURL.setURL(testList[index].orgURL);

        // Call the comparison function
        if (!checkBasicResult(testURL, testList[index]))
            retVal = false;
    }

    return retVal;
}
Sequence FunctionUnparsedText::createSequence(DynamicContext* context, int flags) const
{
  Item::Ptr uriArg = getParamNumber(1, context)->next(context);
  
  if(uriArg.isNull()) {
    return Sequence(context->getMemoryManager());
  }
  
  const XMLCh *uri = uriArg->asString(context);

  if(!XPath2Utils::isValidURI(uri, context->getMemoryManager()))
    XQThrow(FunctionException, X("FunctionUnparsedText::createSequence"), X("The argument to fn:unparsed-text() is not a valid URI [err:XTDE1170]"));

  // TBD Implement a URIResolver method for resolving unparsed text - jpcs

  const XMLCh *baseUri = context->getBaseURI();

  InputSource *srcToUse = 0;
  if(context->getXMLEntityResolver()){
    XMLResourceIdentifier resourceIdentifier(XMLResourceIdentifier::UnKnown, uri, 0, XMLUni::fgZeroLenString, baseUri);
    srcToUse = context->getXMLEntityResolver()->resolveEntity(&resourceIdentifier);
  }

  if(srcToUse == 0) {
    try {
      // Resolve the uri against the base uri
      XMLURL urlTmp;

      if(baseUri && *baseUri) {
        urlTmp.setURL(baseUri, uri);
      }
      else {
        urlTmp.setURL(uri);
      }

      srcToUse = new URLInputSource(urlTmp);
    }
    catch(const MalformedURLException &e) {
    }
  }

  if(srcToUse == 0) {
    // It's not a URL, so let's assume it's a local file name.
    if(baseUri && *baseUri) {
      AutoDeallocate<XMLCh> tmpBuf(XMLPlatformUtils::weavePaths(baseUri, uri), XMLPlatformUtils::fgMemoryManager);
      srcToUse = new LocalFileInputSource(tmpBuf);
    }
    else {
      srcToUse = new LocalFileInputSource(uri);
    }
  }

  Janitor<InputSource> janIS(srcToUse);

  if(getNumArgs() == 2) {
    const XMLCh *encoding = getParamNumber(2, context)->next(context)->asString(context);
    srcToUse->setEncoding(encoding);
  }

  XMLBuffer result;
  try {
    BinInputStream *stream = srcToUse->makeStream();
    if(stream == NULL) {
      XMLBuffer buf;
      buf.set(X("Cannot read unparsed content from "));
      buf.append(uri);
      buf.append(X(" [err:XTDE1170]"));
      XQThrow2(FunctionException,X("FunctionUnparsedText::createSequence"), buf.getRawBuffer());
    }
    Janitor<BinInputStream> janStream(stream);

#ifdef HAVE_GETCONTENTTYPE
    if(FunctionMatches::matches(stream->getContentType(), X("(text|application)/(xml|[^ +;]+\\+xml)"), X("i"))) {
      srcToUse->setEncoding(0);
      srcToUse->setEncoding(FindXMLEncoding().start(*srcToUse, context));
    }
#endif

    XPath2Utils::readSource(stream, context->getMemoryManager(), result, srcToUse->getEncoding());
  }
  catch(XMLException &e) {
    XMLBuffer buf;
    buf.set(X("Exception reading unparsed content: "));
    buf.append(e.getMessage());
    buf.append(X(" [err:XTDE1190]"));
    XQThrow2(FunctionException,X("FunctionUnparsedText::createSequence"), buf.getRawBuffer());
  }

  return Sequence(context->getItemFactory()->createString(result.getRawBuffer(), context), context->getMemoryManager());
}