I will try to expline , I am using html-xml , when I try to use xquery with cdata and node() I don't get the <input> from html (it seems that it drop it out) , how can I get those html varible inside xquery? do I need to use template , I will be glad for littel example.
Thanx
Gadi
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I have tryed out the example of sasa with out any lack, I try to use html-to-xml but I got error from xquery, I will be glad if you can post example also with html-to-xml.
Thanx Again
Gadi
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
The problem is in template processor around XQuery expression.
template should replace my_xpath with something. However, syntax should be:
${my_xpath} instead of {$my_xpath}.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
The error that you're getting "Variable $item has not been declared" tells you what's missing. Doing a visual delta from the example to what you have shows that you need:
declare variable $item as node() external;
So your xquery should look like:
<xquery>
<xq-param name="item"><var name="item"/></xq-param>
<xq-expression>
<template>
<![CDATA[
declare variable $item as node() external;
let $title := data($item//h1)
The "<xq-param name="item"><var name="item"/></xq-param>" part passes the variable "item" into the XQuery but then you have to declare the variable in XQuery. (Think of the difference between passing a variable to a function and the function declaration itself.)
Hope this helps.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi
Thanx again for helping me, I am now face in new problem .
I have some html file that has <input> , If I use xpath expression it work and I can see the input value.
but when I try to get <inpu> value from [!CDATA[declare variable $doc as node() external; I don't see the input varible all other <div>,<b> it work.
I am using let $textb := data($doc//*[td='test']/following::input)
thanx
Gadi
Thanx, I have found other problem with data() and some input varible, I have past it in the forum.
Thanx agin
Hi
I will try to expline , I am using html-xml , when I try to use xquery with cdata and node() I don't get the <input> from html (it seems that it drop it out) , how can I get those html varible inside xquery? do I need to use template , I will be glad for littel example.
Thanx
Gadi
Please check this thread:
https://sourceforge.net/forum/message.php?msg_id=4074496
I beleave that your problem is similar.
Vladimir.
Can you please send the full example?
Hi, Vladimir
I have tryed out the example of sasa with out any lack, I try to use html-to-xml but I got error from xquery, I will be glad if you can post example also with html-to-xml.
Thanx Again
Gadi
Please send me your example that doesn't work in order to try to fix it.
<config>
<var-def name="searchEngine">
testpage
</var-def>
<var-def name="startUrl">http://mytest.net/mytest.html</var-def>
<file action="write" path="data/${searchEngine}_content.xml">
</file>
Hi, Vladimir
I post here in the forum an example, Can You please help me.
Thanx
Gadi
first problem:
<xq-param name="item"><var name="item"/></xq-param>
where you don't have item variable previously defined in the web-harvest execution context.
Hi , Vladimir
I also had var-def to item and still I got xquery error?
Thanx Agai
Gadi
:)
The problem is in template processor around XQuery expression.
template should replace my_xpath with something. However, syntax should be:
${my_xpath} instead of {$my_xpath}.
Hi , Vladimir
I still get xquery error, I think its somthing releted to $item , This is what I try to do:
<?xml version="1.0" encoding="UTF-8"?>
<config>
<var-def name="url">
<template> http://mytest.com/test.html</template>
</var-def>
<var-def name="referencias">
<html-to-xml>
<http url="${url}"/>
</html-to-xml>
</var-def>
<file action="write" path="test/test.xml" charset="UTF-8">
<![CDATA[ <?xml version="1.0" encoding="UTF-8"?>
<scholar>
]]>
<loop item="item" index="i">
<list><var name="referencias"/></list>
<body>
<xquery>
<xq-param name="item"><var name="item"/></xq-param>
<xq-expression>
<template>
<![CDATA[
let $title := data($item//h1)
return
<referencia>
<title>{$title}</title>
</referencia>
]]>
</template>
</xq-expression>
</xquery>
</body>
</loop>
<![CDATA[
</scholar> ]]>
</file>
</config>
It give me error in xquery, In the back example my_path wored but still I got error from $item.
Thanx Again
Gadi
Just follow http://web-harvest.sourceforge.net/samples.php?num=5
The error that you're getting "Variable $item has not been declared" tells you what's missing. Doing a visual delta from the example to what you have shows that you need:
declare variable $item as node() external;
So your xquery should look like:
<xquery>
<xq-param name="item"><var name="item"/></xq-param>
<xq-expression>
<template>
<![CDATA[
declare variable $item as node() external;
let $title := data($item//h1)
return
<referencia>
<title>{$title}</title>
</referencia>
]]>
</template>
</xq-expression>
</xquery>
The "<xq-param name="item"><var name="item"/></xq-param>" part passes the variable "item" into the XQuery but then you have to declare the variable in XQuery. (Think of the difference between passing a variable to a function and the function declaration itself.)
Hope this helps.