本文整理汇总了C++中XMLURL::setURL方法的典型用法代码示例。如果您正苦于以下问题:C++ XMLURL::setURL方法的具体用法?C++ XMLURL::setURL怎么用?C++ XMLURL::setURL使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XMLURL
的用法示例。
在下文中一共展示了XMLURL::setURL方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: basicURLTest
//.........这里部分代码省略.........
, L"user"
}
, {
L" file://[email protected]/path1/path2/file.txt#fragment"
, L"file://[email protected]/path1/path2/file.txt#fragment"
, XMLURL::File
, 0
, L"fragment"
, L"host"
, L"/path1/path2/file.txt"
, 0
, 0
, L"user"
}
, {
L"http://host:90/path1/path2/file.txt"
, L"http://host:90/path1/path2/file.txt"
, XMLURL::HTTP
, 90
, 0
, L"host"
, L"/path1/path2/file.txt"
, 0
, 0
, 0
}
, {
L"http://host/path1/path2/file.txt"
, L"http://host/path1/path2/file.txt"
, XMLURL::HTTP
, 80
, 0
, L"host"
, L"/path1/path2/file.txt"
, 0
, 0
, 0
}
, {
L"ftp://"
, L"ftp://"
, XMLURL::FTP
, 21
, 0
, 0
, 0
, 0
, 0
, 0
}
, {
L"ftp://[email protected]"
, L"ftp://[email protected]"
, 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;
}
示例2: createSequence
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());
}