xml - How i can have counter in xquery? -
I'm using XQuery in the present- db and I want to use a counter. For example, I have this code:
Exquisite version "3.0"; $ S in $ P for $ S: = Data (DOC (Cockat ('/ db / index /', $ P, '.html')) // h1) $$ return as a result of IN $ S & lt; A class = "libraryIndexlink" href = "http://library.net/newindex.aspx?pid=102834&bookID=106201&pageIndex={$P}&language=1#p0" & gt; {$ Result} & lt; / A & gt; I need to post it as follows: language = 1 # p counter variable is as follows. For example: language = 1 # p0 "& gt; language = 1 # p1" & gt; I write this code: declare the function local: prod2ndDigit () {$ $ x (0 to 10 This code works, But there is a logical error. My second code is: local: prod2ndDigit ()
This code does not work.
The final code is:
Declare the function locally: prod2ndDigit () {$ x back in (from 0 to 10) $ counter to $ P for $ 351: Counter & gt; {$ X} & lt; / Counter & Data; (Doctor (COCAT ('/ db / INDEX /', $ P, '.HTML ')) // h1) $ s As a result, $ s returns But this code has a logical error. I write this code But this return is the location of an integer in false : $ C: $ 0 back $ C = $ C + 1
The argument you are using does not apply to functional programming languages such as XQuery Is. I think you want to reinvent it on each h1 element and want to include a mounting counter it is actually even simpler than you imagine: $ Key in data $ Key For $ $ (cockat ('/ db / INDEX /', $ P, '.html')) // h1) Returns & lt; a class = "libraryIndexlink" href = "http://library.net/newindex.aspx?pid=102834&bookID=106201&PageIndex={$P}& language = 1 #p {$ Key - 1} "& gt; {$ Result} & lt; / A & gt; at $ of statement gives you status, that means you want the counter to start with 0, but always in the XQuery view Position 1 starts at, so we use the code - 1 . You have to keep XQuery function calls or variables in curly braces, what you did for $ P , but not for local: prod2ndDigit () . This code is let's $ C: = 0 back to $ C = $ C + 1 return false is correct. You are using the = operator, which means the equivalent in XQuery. You probably wanted to write an assignment, which is : = for the operator. Also, it seems that you want to increase the counter. Keep in mind that XQuery is a functional language, as I said earlier , So that you can always manipulate a variable you can always create a new $ counter variable and the old value of the shadow, but you can use other languages such as Viareb while doing c, Java, Python and so on and in other languages Can not change. I do not mind what you want to achieve with your function local: prod2ndDigit () . It gives a sequence of items, but I do not see the use case here.
Comments
Post a Comment