-
Notifications
You must be signed in to change notification settings - Fork 88
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implementing current()
#73
Comments
|
Doesn't that only select Edit: wow that actually worked.. Thanks man! |
Scrap that, it seems it didn't work, it always picks the first one in this case: |
Hello, Need a sample document to test. or try this |
That gives the same result. Its strange, as I was really under the impression your solution first worked.. Anyway, this is a simplified version of the file: <?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="MeasDataCollection.xsl"?>
<measCollecFile xmlns="http://www.3gpp.org/ftp/specs/archive/32_series/32.435#measCollec">
<measData>
<managedElement localDn="foobar.example.com" />
<measInfo measInfoId="metric_name">
<measType p="1">field1</measType>
<measType p="2">field2</measType>
<measValue measObjLdn="identifier">
<r p="1">31854</r>
<r p="2">159773</r>
</measValue>
</measInfo>
<measInfo measInfoId="metric_name2">
<measType p="1">field3</measType>
<measType p="2">field4</measType>
<measValue measObjLdn="identifier">
<r p="1">1234</r>
<r p="2">567</r>
</measValue>
</measInfo>
</measData>
</measCollecFile> And the selected node is each time |
like this
|
That's even worse, now all metrics have field name The Path is run on each |
using the nested query to solve. like this for _,n:=range xmlquery.Find(doc,"//r[@p]")
{
for _,nn:=range xmlquery.Find(n,`../../measType[@p='`+n.SelectAttr("p")+`']`){}
} |
Well, yeah. I can't change the code. I'm using telegraf: https://github.com/influxdata/telegraf/blob/6dc2b99549b3fc4684295ebcd2975cee96a1fa28/plugins/parsers/xpath/parser.go#L419-L447 |
I tested |
Indeed, see GO playground vs XPather. Can I help with trying to fix it? Edit: And what should be the correct path be after the fix? |
|
No, I have an Your xpath selects every r that has a corresponding measType. |
@zhengchun any update on this? Can I help to fix this? |
@Hipska , You can try to fix this and submit PR. |
I would love to fix it, but I don't see where the bug is. |
Sorry,I no idea how to implement |
Oh, but it seems you fixed it? |
I just fixed this expression |
Hmm, then this playground should return 4 nodes, right? https://go.dev/play/p/qeMkl0NqoOT Edit: nevermind, there is no release yet 🙂 https://go.dev/play/p/sI48ALhbizY 👍 |
I just tested latest version of telegraf (which includes the latest version of this library), but my use-case seems still not to be solved. I'm also not sure what the correct xpath for my problem should be. Edit: See the following https://go.dev/play/p/ozvF3CfdDXT
Do You agree? If not, what should my second xpath query be to achieve this wanted result? |
@Hipska , The actually result from your go code execute is correct, your expect result is not right.
xmlquery.Find(n, You should change your query from You can try take your xpath expression execute on the another program language and see the result. |
@zhengchun sorry for this late response. the code itself cannot be changed as this is what telegraf is doing. So I am looking for the correct xpath query to achieve my wanted result.. |
So, what is your expected xpath if we can implement the In the above example, if you can nested You can provide an example and what is you expected result. |
Hi, sorry to be so late on this.. In the telegraf config, I'm only able to pass a string, see earlier shared code. So I need a single string/xpath that returns the expected |
I find a solution that saving the query node 'n' as a local variable used |
Yeah, the whole reason of this issue is because of the
|
@zhengchun can you point me to where I could implement that? |
Implementing |
Okay, but where could I start implementing it? |
These are only my guesses and cannot be guaranteed to be right. |
I'm wondering why the
current()
function hasn't been implemented, and if it would make much time to do so.I'm currently in the situation where I would need a query like
//cd[@title=current()/@ref]
. The node navigator used for the expression evaluate isn't the document root, but a previously selected node.The text was updated successfully, but these errors were encountered: