xslt - Error: "the focus is undefined" -
i use xslt (fpml root of document):
<?xml version="1.0" encoding="utf-8"?> <xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/xsl/transform"> <xsl:template match="/"> <xsl:sequence select="/fpml"/> </xsl:template> </xsl:stylesheet>
within code:
if(schema.isvalid()) { qxmlschemavalidator validator(schema); qbytearray data(this->xmltextedit->toplaintext().tostdstring().c_str()); qbuffer buffer(&data); buffer.open(qiodevice::readonly); if (validator.validate(&buffer)) qdebug() << "instance document valid"; else qdebug() << "instance document invalid"; qxmlquery query(qxmlquery::xslt20); query.setfocus(&buffer); qdebug() << qdir::current(); qurl xslt("test__.xslt"); if( xslt.isvalid()) { query.setquery(xslt); qstring result; query.evaluateto(&result); this->xsltextedit->setplaintext(result); } }
and got error:
at line 10, column 18: focus undefined
when googling found this:
if function user-defined function, converted argument values bound formal parameters of function, , function body evaluated. value returned function body converted declared return type of function applying function conversion rules.
a function not inherit focus (context item, context position, , context size) environment of function call. during evaluation of function body, focus undefined, except defined action of expression inside function body. use of expression depends on focus when focus undefined results in dynamic error.
but i'm not sure understand. problem in stylesheet ?
the problem came buffer passed focus, apprently silently colsed, after schema validation. added "open"
if(schema.isvalid()) { qxmlschemavalidator validator(schema); qbytearray data(this->xmltextedit->toplaintext().tostdstring().c_str()); qbuffer buffer(&data); buffer.open(qiodevice::readonly); if (validator.validate(&buffer)) qdebug() << "instance document valid"; else qdebug() << "instance document invalid"; qxmlquery query(qxmlquery::xslt20); qdebug() << qdir::current(); qurl xslt("test__.xslt"); if( xslt.isvalid()) { buffer.open(qiodevice::readonly); query.setfocus(&buffer); query.setquery(xslt); qstring result; query.evaluateto(&result); this->xsltextedit->setplaintext(result); } }
Comments
Post a Comment