xml - xslt: contextless 'generate-id'? -


as understand it, xslt function generate-id() return unique id depending on node , context (ancestors).

is there way obtain id dependent on node (and subnodes), , not position in document?

when using xinclude, identical nodes can put multiple locations -- , hence have 2 different ids generated. how can create alphanumeric string identical each instance of node-set inserted document via xinclude?

so have file node.xml:

<?xml version="1.0" encoding="utf-8"?> <node name="joe"/> 

and document.xml:

<?xml version="1.0" encoding="utf-8"?> <document xmlns:xi="http://www.w3.org/2003/xinclude">     <container name="first">         <xi:include href="node.xml"/>     </container>     <container name="second">         <xi:include href="node.xml"/>     </container> </document> 

and process.xslt:

<?xml version="1.0" encoding="utf-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/xsl/transform"> <xsl:template match="container"> not identical different matches of template, although matched <node/> has same content: '<xsl:value-of select="generate-id(node)"/>' appending attributes simple, there might differences deeper down hierarchy, should resolve in different id: '<xsl:value-of select="node/@name"/>' </xsl:template> </xsl:stylesheet> 

process xsltproc --xinclude process.xslt document.xml. need same id/string both occurrences of <node/>, identical.

greetings

argh. this looks remarkably similar. however, not want manually concat values...? not scale in case... maybe can work out using number() feels there should more auto...

ps: using xsltproc, no fancy-pancy... ;-)

the 2 node elements not identical. have same children/attributes/descendants, have different parents , different siblings.

the 2 node elements deep-equal according xpath 2.0 definition of deep-equal function. deep-equal spec no means possible way function specified: read spec , see number of rules have been defined differently. (e.g. dependencies on namespace prefixes, whitespace-only text nodes, in-scope namespaces, base uri, type annotations).

given caveats, there cases useful have function fingerprint(node) such fingerprint(n) = fingerprint(m) if , if deep-equal(n, m). write own function not @ easy write, , might not efficient.

so know why think need it, because there may easier way solve problem.


Comments

Popular posts from this blog

account - Script error login visual studio DefaultLogin_PCore.js -

xcode - CocoaPod Storyboard error: -