Using XSLT extract xpath of all text nodes with value from any xml
I have an xml:
<root>
<child attrib1="1">
<subChild>
<name>subChild1</name>
</subChild>
</child>
<child attrib1="2>
<subChild2>
<name>subChild2</name>
</subChild2>
</child>
I want xslt to generate o/p as follows i.e. xpath and its value:
- /root/child[@attrib1="1]/subChild/name="subChild1"
- /root/child[@attrib1="2]/subChild2/name="subChild2"
xml xslt
add a comment |
I have an xml:
<root>
<child attrib1="1">
<subChild>
<name>subChild1</name>
</subChild>
</child>
<child attrib1="2>
<subChild2>
<name>subChild2</name>
</subChild2>
</child>
I want xslt to generate o/p as follows i.e. xpath and its value:
- /root/child[@attrib1="1]/subChild/name="subChild1"
- /root/child[@attrib1="2]/subChild2/name="subChild2"
xml xslt
For which nodes exactly do you want to generate a path expression? What happened if you had more than one<child attrib1="1"><subChild><name>foo</name></subChild></child>
elements? You paths don't seem to help to uniquely identify elements. Also, which version of XSLT do you use? XPath 3 has w3.org/TR/xpath-functions/#func-path which is certainly generating a more generic and more precise path for the case of all the complications of namespaces and duplicates.
– Martin Honnen
Nov 25 '18 at 16:20
As so often happens, one single example of an input and a corresponding output does not constitute a specification.
– Michael Kay
Nov 25 '18 at 16:36
apologies, i corrected the expected o/p in above. In general, i want to generate xpath for all text nodes in a given xml using xslt.
– rupaj
Nov 25 '18 at 17:00
add a comment |
I have an xml:
<root>
<child attrib1="1">
<subChild>
<name>subChild1</name>
</subChild>
</child>
<child attrib1="2>
<subChild2>
<name>subChild2</name>
</subChild2>
</child>
I want xslt to generate o/p as follows i.e. xpath and its value:
- /root/child[@attrib1="1]/subChild/name="subChild1"
- /root/child[@attrib1="2]/subChild2/name="subChild2"
xml xslt
I have an xml:
<root>
<child attrib1="1">
<subChild>
<name>subChild1</name>
</subChild>
</child>
<child attrib1="2>
<subChild2>
<name>subChild2</name>
</subChild2>
</child>
I want xslt to generate o/p as follows i.e. xpath and its value:
- /root/child[@attrib1="1]/subChild/name="subChild1"
- /root/child[@attrib1="2]/subChild2/name="subChild2"
xml xslt
xml xslt
edited Nov 25 '18 at 18:29
rupaj
asked Nov 25 '18 at 15:14
rupajrupaj
204
204
For which nodes exactly do you want to generate a path expression? What happened if you had more than one<child attrib1="1"><subChild><name>foo</name></subChild></child>
elements? You paths don't seem to help to uniquely identify elements. Also, which version of XSLT do you use? XPath 3 has w3.org/TR/xpath-functions/#func-path which is certainly generating a more generic and more precise path for the case of all the complications of namespaces and duplicates.
– Martin Honnen
Nov 25 '18 at 16:20
As so often happens, one single example of an input and a corresponding output does not constitute a specification.
– Michael Kay
Nov 25 '18 at 16:36
apologies, i corrected the expected o/p in above. In general, i want to generate xpath for all text nodes in a given xml using xslt.
– rupaj
Nov 25 '18 at 17:00
add a comment |
For which nodes exactly do you want to generate a path expression? What happened if you had more than one<child attrib1="1"><subChild><name>foo</name></subChild></child>
elements? You paths don't seem to help to uniquely identify elements. Also, which version of XSLT do you use? XPath 3 has w3.org/TR/xpath-functions/#func-path which is certainly generating a more generic and more precise path for the case of all the complications of namespaces and duplicates.
– Martin Honnen
Nov 25 '18 at 16:20
As so often happens, one single example of an input and a corresponding output does not constitute a specification.
– Michael Kay
Nov 25 '18 at 16:36
apologies, i corrected the expected o/p in above. In general, i want to generate xpath for all text nodes in a given xml using xslt.
– rupaj
Nov 25 '18 at 17:00
For which nodes exactly do you want to generate a path expression? What happened if you had more than one
<child attrib1="1"><subChild><name>foo</name></subChild></child>
elements? You paths don't seem to help to uniquely identify elements. Also, which version of XSLT do you use? XPath 3 has w3.org/TR/xpath-functions/#func-path which is certainly generating a more generic and more precise path for the case of all the complications of namespaces and duplicates.– Martin Honnen
Nov 25 '18 at 16:20
For which nodes exactly do you want to generate a path expression? What happened if you had more than one
<child attrib1="1"><subChild><name>foo</name></subChild></child>
elements? You paths don't seem to help to uniquely identify elements. Also, which version of XSLT do you use? XPath 3 has w3.org/TR/xpath-functions/#func-path which is certainly generating a more generic and more precise path for the case of all the complications of namespaces and duplicates.– Martin Honnen
Nov 25 '18 at 16:20
As so often happens, one single example of an input and a corresponding output does not constitute a specification.
– Michael Kay
Nov 25 '18 at 16:36
As so often happens, one single example of an input and a corresponding output does not constitute a specification.
– Michael Kay
Nov 25 '18 at 16:36
apologies, i corrected the expected o/p in above. In general, i want to generate xpath for all text nodes in a given xml using xslt.
– rupaj
Nov 25 '18 at 17:00
apologies, i corrected the expected o/p in above. In general, i want to generate xpath for all text nodes in a given xml using xslt.
– rupaj
Nov 25 '18 at 17:00
add a comment |
2 Answers
2
active
oldest
votes
As noted in the comments, your question is not entirely clear. Try something like this as your starting point:
XSLT 1.0
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="text" encoding="utf-8" />
<xsl:strip-space elements="*"/>
<xsl:template match="/">
<xsl:for-each select="//text()">
<xsl:apply-templates select="parent::*"/>
<xsl:text>="</xsl:text>
<xsl:value-of select="."/>
<xsl:text>"
</xsl:text>
</xsl:for-each>
</xsl:template>
<xsl:template match="*">
<xsl:apply-templates select="parent::*"/>
<xsl:text>/</xsl:text>
<xsl:value-of select="name()"/>
<xsl:apply-templates select="@*"/>
</xsl:template>
<xsl:template match="@*">
<xsl:text>[@</xsl:text>
<xsl:value-of select="name()"/>
<xsl:text>="</xsl:text>
<xsl:value-of select="."/>
<xsl:text>"]</xsl:text>
</xsl:template>
</xsl:stylesheet>
Thanks michael.hor257k above xslt works and generates desired result ! I am very much new to xslt, tried an alternate xslt as mentioned in below anwser referring to other posts. Which is best source to learn/explore programming using xslt ? w3schools provided very basic intro, where can i learn above advanced programming/functions in xslt ?
– rupaj
Nov 25 '18 at 18:25
I am afraid I am not a good source for such information.
– michael.hor257k
Nov 25 '18 at 19:02
add a comment |
Referring to other posts i tried below xslt, it generates the expected o/p:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output omit-xml-declaration="yes" indent="yes"/>
<xsl:strip-space elements="*"/>
<xsl:variable name="vApos">'</xsl:variable>
<xsl:template match="*[not(*)]">
<xsl:if test="not(*)">
<xsl:apply-templates select="ancestor-or-self::*" mode="path"/>
<xsl:value-of select="concat('=',$vApos,.,$vApos)"/>
<xsl:text>
</xsl:text>
</xsl:if>
</xsl:template>
<xsl:template match="*" mode="path">
<xsl:value-of select="concat('/',name())"/>
<xsl:apply-templates select="@*" mode="path"/>
</xsl:template>
<xsl:template match="@*" mode="path">
<xsl:value-of select="concat('[@',name(), '=',$vApos,.,$vApos,']')"/>
</xsl:template>
</xsl:stylesheet>
Sample i/p xml:
<root id='1'>
<elemA>one</elemA>
<elemA attribute1='first' attribute2='second'>two</elemA>
<elemB attribute='1'>three</elemB>
<elemA >four</elemA>
<elemC attribute='c'>
<elemB attribute='2'>five</elemB>
<elemB attribute='3'>five</elemB>
</elemC>
</root>
Output:
/root[@id='1']/elemA='one'
/root[@id='1']/elemA[@attribute1='first'][@attribute2='second']='two'
/root[@id='1']/elemB[@attribute='1']='three'
/root[@id='1']/elemA='four'
/root[@id='1']/elemC[@attribute='c']/elemB[@attribute='2']='five'
/root[@id='1']/elemC[@attribute='c']/elemB[@attribute='3']='five'
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53468880%2fusing-xslt-extract-xpath-of-all-text-nodes-with-value-from-any-xml%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
As noted in the comments, your question is not entirely clear. Try something like this as your starting point:
XSLT 1.0
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="text" encoding="utf-8" />
<xsl:strip-space elements="*"/>
<xsl:template match="/">
<xsl:for-each select="//text()">
<xsl:apply-templates select="parent::*"/>
<xsl:text>="</xsl:text>
<xsl:value-of select="."/>
<xsl:text>"
</xsl:text>
</xsl:for-each>
</xsl:template>
<xsl:template match="*">
<xsl:apply-templates select="parent::*"/>
<xsl:text>/</xsl:text>
<xsl:value-of select="name()"/>
<xsl:apply-templates select="@*"/>
</xsl:template>
<xsl:template match="@*">
<xsl:text>[@</xsl:text>
<xsl:value-of select="name()"/>
<xsl:text>="</xsl:text>
<xsl:value-of select="."/>
<xsl:text>"]</xsl:text>
</xsl:template>
</xsl:stylesheet>
Thanks michael.hor257k above xslt works and generates desired result ! I am very much new to xslt, tried an alternate xslt as mentioned in below anwser referring to other posts. Which is best source to learn/explore programming using xslt ? w3schools provided very basic intro, where can i learn above advanced programming/functions in xslt ?
– rupaj
Nov 25 '18 at 18:25
I am afraid I am not a good source for such information.
– michael.hor257k
Nov 25 '18 at 19:02
add a comment |
As noted in the comments, your question is not entirely clear. Try something like this as your starting point:
XSLT 1.0
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="text" encoding="utf-8" />
<xsl:strip-space elements="*"/>
<xsl:template match="/">
<xsl:for-each select="//text()">
<xsl:apply-templates select="parent::*"/>
<xsl:text>="</xsl:text>
<xsl:value-of select="."/>
<xsl:text>"
</xsl:text>
</xsl:for-each>
</xsl:template>
<xsl:template match="*">
<xsl:apply-templates select="parent::*"/>
<xsl:text>/</xsl:text>
<xsl:value-of select="name()"/>
<xsl:apply-templates select="@*"/>
</xsl:template>
<xsl:template match="@*">
<xsl:text>[@</xsl:text>
<xsl:value-of select="name()"/>
<xsl:text>="</xsl:text>
<xsl:value-of select="."/>
<xsl:text>"]</xsl:text>
</xsl:template>
</xsl:stylesheet>
Thanks michael.hor257k above xslt works and generates desired result ! I am very much new to xslt, tried an alternate xslt as mentioned in below anwser referring to other posts. Which is best source to learn/explore programming using xslt ? w3schools provided very basic intro, where can i learn above advanced programming/functions in xslt ?
– rupaj
Nov 25 '18 at 18:25
I am afraid I am not a good source for such information.
– michael.hor257k
Nov 25 '18 at 19:02
add a comment |
As noted in the comments, your question is not entirely clear. Try something like this as your starting point:
XSLT 1.0
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="text" encoding="utf-8" />
<xsl:strip-space elements="*"/>
<xsl:template match="/">
<xsl:for-each select="//text()">
<xsl:apply-templates select="parent::*"/>
<xsl:text>="</xsl:text>
<xsl:value-of select="."/>
<xsl:text>"
</xsl:text>
</xsl:for-each>
</xsl:template>
<xsl:template match="*">
<xsl:apply-templates select="parent::*"/>
<xsl:text>/</xsl:text>
<xsl:value-of select="name()"/>
<xsl:apply-templates select="@*"/>
</xsl:template>
<xsl:template match="@*">
<xsl:text>[@</xsl:text>
<xsl:value-of select="name()"/>
<xsl:text>="</xsl:text>
<xsl:value-of select="."/>
<xsl:text>"]</xsl:text>
</xsl:template>
</xsl:stylesheet>
As noted in the comments, your question is not entirely clear. Try something like this as your starting point:
XSLT 1.0
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="text" encoding="utf-8" />
<xsl:strip-space elements="*"/>
<xsl:template match="/">
<xsl:for-each select="//text()">
<xsl:apply-templates select="parent::*"/>
<xsl:text>="</xsl:text>
<xsl:value-of select="."/>
<xsl:text>"
</xsl:text>
</xsl:for-each>
</xsl:template>
<xsl:template match="*">
<xsl:apply-templates select="parent::*"/>
<xsl:text>/</xsl:text>
<xsl:value-of select="name()"/>
<xsl:apply-templates select="@*"/>
</xsl:template>
<xsl:template match="@*">
<xsl:text>[@</xsl:text>
<xsl:value-of select="name()"/>
<xsl:text>="</xsl:text>
<xsl:value-of select="."/>
<xsl:text>"]</xsl:text>
</xsl:template>
</xsl:stylesheet>
answered Nov 25 '18 at 17:48
michael.hor257kmichael.hor257k
76.1k42237
76.1k42237
Thanks michael.hor257k above xslt works and generates desired result ! I am very much new to xslt, tried an alternate xslt as mentioned in below anwser referring to other posts. Which is best source to learn/explore programming using xslt ? w3schools provided very basic intro, where can i learn above advanced programming/functions in xslt ?
– rupaj
Nov 25 '18 at 18:25
I am afraid I am not a good source for such information.
– michael.hor257k
Nov 25 '18 at 19:02
add a comment |
Thanks michael.hor257k above xslt works and generates desired result ! I am very much new to xslt, tried an alternate xslt as mentioned in below anwser referring to other posts. Which is best source to learn/explore programming using xslt ? w3schools provided very basic intro, where can i learn above advanced programming/functions in xslt ?
– rupaj
Nov 25 '18 at 18:25
I am afraid I am not a good source for such information.
– michael.hor257k
Nov 25 '18 at 19:02
Thanks michael.hor257k above xslt works and generates desired result ! I am very much new to xslt, tried an alternate xslt as mentioned in below anwser referring to other posts. Which is best source to learn/explore programming using xslt ? w3schools provided very basic intro, where can i learn above advanced programming/functions in xslt ?
– rupaj
Nov 25 '18 at 18:25
Thanks michael.hor257k above xslt works and generates desired result ! I am very much new to xslt, tried an alternate xslt as mentioned in below anwser referring to other posts. Which is best source to learn/explore programming using xslt ? w3schools provided very basic intro, where can i learn above advanced programming/functions in xslt ?
– rupaj
Nov 25 '18 at 18:25
I am afraid I am not a good source for such information.
– michael.hor257k
Nov 25 '18 at 19:02
I am afraid I am not a good source for such information.
– michael.hor257k
Nov 25 '18 at 19:02
add a comment |
Referring to other posts i tried below xslt, it generates the expected o/p:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output omit-xml-declaration="yes" indent="yes"/>
<xsl:strip-space elements="*"/>
<xsl:variable name="vApos">'</xsl:variable>
<xsl:template match="*[not(*)]">
<xsl:if test="not(*)">
<xsl:apply-templates select="ancestor-or-self::*" mode="path"/>
<xsl:value-of select="concat('=',$vApos,.,$vApos)"/>
<xsl:text>
</xsl:text>
</xsl:if>
</xsl:template>
<xsl:template match="*" mode="path">
<xsl:value-of select="concat('/',name())"/>
<xsl:apply-templates select="@*" mode="path"/>
</xsl:template>
<xsl:template match="@*" mode="path">
<xsl:value-of select="concat('[@',name(), '=',$vApos,.,$vApos,']')"/>
</xsl:template>
</xsl:stylesheet>
Sample i/p xml:
<root id='1'>
<elemA>one</elemA>
<elemA attribute1='first' attribute2='second'>two</elemA>
<elemB attribute='1'>three</elemB>
<elemA >four</elemA>
<elemC attribute='c'>
<elemB attribute='2'>five</elemB>
<elemB attribute='3'>five</elemB>
</elemC>
</root>
Output:
/root[@id='1']/elemA='one'
/root[@id='1']/elemA[@attribute1='first'][@attribute2='second']='two'
/root[@id='1']/elemB[@attribute='1']='three'
/root[@id='1']/elemA='four'
/root[@id='1']/elemC[@attribute='c']/elemB[@attribute='2']='five'
/root[@id='1']/elemC[@attribute='c']/elemB[@attribute='3']='five'
add a comment |
Referring to other posts i tried below xslt, it generates the expected o/p:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output omit-xml-declaration="yes" indent="yes"/>
<xsl:strip-space elements="*"/>
<xsl:variable name="vApos">'</xsl:variable>
<xsl:template match="*[not(*)]">
<xsl:if test="not(*)">
<xsl:apply-templates select="ancestor-or-self::*" mode="path"/>
<xsl:value-of select="concat('=',$vApos,.,$vApos)"/>
<xsl:text>
</xsl:text>
</xsl:if>
</xsl:template>
<xsl:template match="*" mode="path">
<xsl:value-of select="concat('/',name())"/>
<xsl:apply-templates select="@*" mode="path"/>
</xsl:template>
<xsl:template match="@*" mode="path">
<xsl:value-of select="concat('[@',name(), '=',$vApos,.,$vApos,']')"/>
</xsl:template>
</xsl:stylesheet>
Sample i/p xml:
<root id='1'>
<elemA>one</elemA>
<elemA attribute1='first' attribute2='second'>two</elemA>
<elemB attribute='1'>three</elemB>
<elemA >four</elemA>
<elemC attribute='c'>
<elemB attribute='2'>five</elemB>
<elemB attribute='3'>five</elemB>
</elemC>
</root>
Output:
/root[@id='1']/elemA='one'
/root[@id='1']/elemA[@attribute1='first'][@attribute2='second']='two'
/root[@id='1']/elemB[@attribute='1']='three'
/root[@id='1']/elemA='four'
/root[@id='1']/elemC[@attribute='c']/elemB[@attribute='2']='five'
/root[@id='1']/elemC[@attribute='c']/elemB[@attribute='3']='five'
add a comment |
Referring to other posts i tried below xslt, it generates the expected o/p:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output omit-xml-declaration="yes" indent="yes"/>
<xsl:strip-space elements="*"/>
<xsl:variable name="vApos">'</xsl:variable>
<xsl:template match="*[not(*)]">
<xsl:if test="not(*)">
<xsl:apply-templates select="ancestor-or-self::*" mode="path"/>
<xsl:value-of select="concat('=',$vApos,.,$vApos)"/>
<xsl:text>
</xsl:text>
</xsl:if>
</xsl:template>
<xsl:template match="*" mode="path">
<xsl:value-of select="concat('/',name())"/>
<xsl:apply-templates select="@*" mode="path"/>
</xsl:template>
<xsl:template match="@*" mode="path">
<xsl:value-of select="concat('[@',name(), '=',$vApos,.,$vApos,']')"/>
</xsl:template>
</xsl:stylesheet>
Sample i/p xml:
<root id='1'>
<elemA>one</elemA>
<elemA attribute1='first' attribute2='second'>two</elemA>
<elemB attribute='1'>three</elemB>
<elemA >four</elemA>
<elemC attribute='c'>
<elemB attribute='2'>five</elemB>
<elemB attribute='3'>five</elemB>
</elemC>
</root>
Output:
/root[@id='1']/elemA='one'
/root[@id='1']/elemA[@attribute1='first'][@attribute2='second']='two'
/root[@id='1']/elemB[@attribute='1']='three'
/root[@id='1']/elemA='four'
/root[@id='1']/elemC[@attribute='c']/elemB[@attribute='2']='five'
/root[@id='1']/elemC[@attribute='c']/elemB[@attribute='3']='five'
Referring to other posts i tried below xslt, it generates the expected o/p:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output omit-xml-declaration="yes" indent="yes"/>
<xsl:strip-space elements="*"/>
<xsl:variable name="vApos">'</xsl:variable>
<xsl:template match="*[not(*)]">
<xsl:if test="not(*)">
<xsl:apply-templates select="ancestor-or-self::*" mode="path"/>
<xsl:value-of select="concat('=',$vApos,.,$vApos)"/>
<xsl:text>
</xsl:text>
</xsl:if>
</xsl:template>
<xsl:template match="*" mode="path">
<xsl:value-of select="concat('/',name())"/>
<xsl:apply-templates select="@*" mode="path"/>
</xsl:template>
<xsl:template match="@*" mode="path">
<xsl:value-of select="concat('[@',name(), '=',$vApos,.,$vApos,']')"/>
</xsl:template>
</xsl:stylesheet>
Sample i/p xml:
<root id='1'>
<elemA>one</elemA>
<elemA attribute1='first' attribute2='second'>two</elemA>
<elemB attribute='1'>three</elemB>
<elemA >four</elemA>
<elemC attribute='c'>
<elemB attribute='2'>five</elemB>
<elemB attribute='3'>five</elemB>
</elemC>
</root>
Output:
/root[@id='1']/elemA='one'
/root[@id='1']/elemA[@attribute1='first'][@attribute2='second']='two'
/root[@id='1']/elemB[@attribute='1']='three'
/root[@id='1']/elemA='four'
/root[@id='1']/elemC[@attribute='c']/elemB[@attribute='2']='five'
/root[@id='1']/elemC[@attribute='c']/elemB[@attribute='3']='five'
answered Nov 25 '18 at 18:20
rupajrupaj
204
204
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53468880%2fusing-xslt-extract-xpath-of-all-text-nodes-with-value-from-any-xml%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
For which nodes exactly do you want to generate a path expression? What happened if you had more than one
<child attrib1="1"><subChild><name>foo</name></subChild></child>
elements? You paths don't seem to help to uniquely identify elements. Also, which version of XSLT do you use? XPath 3 has w3.org/TR/xpath-functions/#func-path which is certainly generating a more generic and more precise path for the case of all the complications of namespaces and duplicates.– Martin Honnen
Nov 25 '18 at 16:20
As so often happens, one single example of an input and a corresponding output does not constitute a specification.
– Michael Kay
Nov 25 '18 at 16:36
apologies, i corrected the expected o/p in above. In general, i want to generate xpath for all text nodes in a given xml using xslt.
– rupaj
Nov 25 '18 at 17:00