I'm using xsl:stylesheet
Processing Instruction in my XML. Is there anyway to select this PI using XPath ? If so how ?
相关问题
- Illegal to have multiple roots (start tag in epilo
- Newtonsoft DeserializeXNode expands internal array
- how to use special characters like '<'
- XPath How to retrieve the value of a table cell fr
- XML - XSLT - document() function inside count() fu
相关文章
- scrapy爬虫数据清洗
- Creating XML Elements without namespace declaratio
- Get Attribute Value From Simple XML Using JQuery /
- Directly signing an Office Word document using XML
- When sending XML to JMS should I use TextMessage o
- Fragment Content Overlaps Toolbar and Bottom Navig
- Getting “Error: Missing Constraints in ConstraintL
- xslt localization
Use
processing-instruction()
node-test.In general, a processing instruction can be selected using the
processing-instruction()
node test.More specifically, one can include as argument the name (target) of the wanted PI node.
Use:
This selects any processing instruction with name
xsl-stylesheet
that is defined at the global level (is sibling of the top element).Do note that
xsl:stylesheet
is an invalid PI target for a PI. A colon':'
is used to delimit a namespace prefix from the local name -- however a processing instruction target cannot belong to a namespace. As per the W3c XPath Specification:"A processing instruction has an expanded-name: the local part is the processing instruction's target; the namespace URI is null."
Also according to the W3C document: "Associating Style Sheets with XML documents 1.0", the target of the PI that associates a stylesheet to an XML document must be:
"xml-stylesheet"
-- not"xsl:stylesheet"
or"xsl-stylesheet"
.Here is a complete example:
When this transformation is applied against the following XML document:
the XPath expression is evaluated and the selected PI node is output:
A processing-instruction hat two parts target and data with the syntax:
If you use:
It will only return the data part, in the example of Dimitre Novatchev, it returns:
So the string value of a processing instruction is the data part. select expression of
<xsl:value-of
is evaluated and the resulting object is converted to a string, like a implicit call to thestring()
function.