Jump to content

Izee

Members
  • Posts

    4
  • Joined

  • Last visited

Izee's Achievements

Newbie

Newbie (1/7)

0

Reputation

  1. Izee

    XQuery/XPath: question

    Yes, incrementing is $i++ in PHP but actually I'm not using PHP for this query. I mean: all the code you see there is XQuery only.Maybe I'm trying do to something complex for XQuery? Do I really have to use PHP to make this query work? Maybe if I don't want to get mad it could be the solution.WTF... ok I imagined correctly
  2. Izee

    XQuery/XPath: question

    Yes musical data I'm just getting to know XQuery and I'm starting to get mad. I can really say that PHP is my type. But for this task I think XQuery should be better. In this query ( I don't really know what you mean with WTF but i can imagine )the only problem is: incremet that variable. Why doesn't it work?Mad really mad. And time is going away.Anyway thank you for support
  3. Izee

    XQuery/XPath: question

    "Works" means that gives me what I need. The problem was that I need it as an option.And because I have to specify what kind of parameter is, they are elements:declare function p:funct($input as element(input)*)(: etc... I found this solution: maybe was only my Xpath ignorance :Pfor $d in doc("blabla.xml")//tag/tag2[tagsent=$actualparameter]Where the parameter is p:funct(<tagsent><tagsent2>A</tagsent2></tagsent>)I hope it is clear.But now I have a new problem. I have a variable $input like this:<input><pitch><step>C</step><octave>4</octave></pitch><pitch><step>D</step><octave>4</octave></pitch><pitch><step>E</step><octave>4</octave></pitch></input>I have to find these elements in sequence into an XML file. They may occur several times.let $n := count($input/pitch)for $d in doc("musicblabla.xml")//measure/note[pitch=$input/pitch[position()=1]]for $i in (1 to $n) return if ($i = 2) (: if it's the first time then $d[pitch=$input/pitch[position()=1]] (: print the match with the first note of input else $d[pitch=$input/pitch[position()=$i]] (: the second, third time etc... It seems like it does not increment $i, so the position also does not increment.Something like 11111, 22222, 33333What can I do?
  4. Hi, I'm working on a function that receives XML tags and insert the actual parameter into an XPath expressions to retrieve documents with those tags.The problem is that if I use the parameter to move the context node ( / ) the query works, but I need to insert it like an option ( [...] )So:for $d in doc("blabla.xml")//tag/tag2/$actualparameter <--- this worksfor $d in doc("blabla.xml")//tag/tag2[$actualparameter] <--- this doesn't workI think that the actual parameter contains elements, so it's the same if I write:for $d in doc("blabla.xml")//tag/tag2/<tagsent><tagsent2>A</tagsent2></tagsent>(works)orfor $d in doc("blabla.xml")//tag/tag2[<tagsent><tagsent2>A</tagsent2></tagsent>](doesn't work)What can I do?Thank you and sorry for my english
×
×
  • Create New...