【问题标题】:How to get processing instruction from XML in Xalan program?如何在 Xalan 程序中从 XML 获取处理指令?
【发布时间】:2012-03-16 15:45:49
【问题描述】:

我正在使用 Xalan,想知道如何获取处理指令。 我想获取样式表处理指令。

谢谢

【问题讨论】:

标签: xalan


【解决方案1】:
        XMLPlatformUtils::Initialize();
        XPathEvaluator::initialize();
        {
        const XalanDOMString            theFileName(fileName);
        const LocalFileInputSource      theInputSource(theFileName.c_str());


        XalanSourceTreeInit             theSourceTreeInit;
        XalanSourceTreeDOMSupport       theDOMSupport;
        XalanSourceTreeParserLiaison    theLiaison(theDOMSupport);
        theDOMSupport.setParserLiaison(&theLiaison);

        XalanDocument* const            theDocument =
                                          theLiaison.parseXMLStream(theInputSource);

       if(!theDocument) {
           std::cerr << "Failed to create XalanDocument" << std::endl;
           retValue = -1;
       }

       XalanDocumentPrefixResolver     thePrefixResolver(theDocument);
       XPathEvaluator                  theEvaluator;

       XalanNode* const rootContextNode = theEvaluator.selectSingleNode(
                                                theDOMSupport, theDocument,
                             XalanDOMString("/processing-instruction('xml-stylesheet')").c_str(),
                                                thePrefixResolver);

       if(rootContextNode) {
//<Now do whatever u want :)>
       }

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2023-04-08
    • 1970-01-01
    • 2023-03-03
    • 2011-03-07
    • 1970-01-01
    • 2020-09-08
    • 2014-09-12
    • 2018-07-09
    相关资源
    最近更新 更多