Is it possible to distinguish <node/>
and <n开发者_高级运维ode></node>
with xsl?
XSLT works on the parsed XML data model (XML tree). XML data model makes no difference between self-closing elements and empty elements with separate start and end tags. They are both just elements that have no child nodes at all (text, element, comment, etc). So in the phase where XSLT processor gets it hands down to the given XML structure, all this lexical variation is already lost.
Only solution that comes to my mind is to use a parser that has some extensions to add lexical data to the parsed tree. This could be based on modifying the tree by adding new elements that represent different lexical events. Then your XSLT code could identify those nodes added by the parser and process accordingly.
But in the end, if you are not asking this just because it interest you, but you really need to distinguish between <node/>
and <node></node>
in your XSLT document, then there is probably something wrong in your toolchain/process model.
No, nor with any conformant XML processor.
(Unless you have some lexical information you might use to deduce which form of markup had been used - SAX locators maybe.)
精彩评论