Thanks,
Everything works now.
Actually I'm already using Captcha block with some minor changes.
josh
solprovider-2 wrote:
>
> The code you supplied will not work.
>
> With XML like:
> <rootElement>
> <captcha/>
> <captcha/>
> ...
> <captcha>returnValue</captcha>
> </rootElement>
>
> You would expect returnValue to be the text contents of the last
> captcha element under root. returnValue will be placed in a session
> attribute and used in pipeline variables.
> <map:transform src="variables.xsl">
> <map:parameter name="nodeFromSession"
> value="{session-attr:captcha-result}"/>
> <map:parameter name="nodeFromFlow"
> value="{flow-attribute:captcha-result}"/>
>
> The nodeValue of an element is always blank. Much of the W3C's role
> is protecting the jobs of IT professionals. W3C XML has a layer of
> extra nodes that interfere with comprehension by normal people. For
> <myNode>myText</myNode>, the XML is like:
> Node("myNode").getChild("#text").getNodeValue()
> Assuming the node has no children elements, use this function:
>
> function getText(node){
> var text = "";
> if(node.getFirstChild() != null) text =
> node.getFirstChild().getNodeValue();
> return text;
> }
>
> I use print statements to test my JS. The results appear on the console.
> var captchaUserEntry = captchaUserEntries.item(i);
> var captchaUserContent = getText(captchaUserEntry);
> print("" + i + "=" + captchaUserContent);
>
> I am uncertain about scope in JavaScript. I would never declare a
> variable inside a block and expect the variable to be available
> outside the block, but that rule is a LCD from using many programming
> languages. If JS had an issue, this code should error about accessing
> a missing property "nodeValue" from a null object.
>
> For other reading, Cocoon has a standard unstable "captcha" block that
> has been discussed on the Cocoon and Lenya MLs.
>
> solprovider
>
>
> On 10/7/07, Josh2007 <[EMAIL PROTECTED]> wrote:
>> Everything works fine with the function.
>> I've been able to retrieve my xml and to fetch the required node.
>> Problem, I can't fetch any nodeValue.
>>
>> To check, I save the node.nodeValue content in a session attribute and
>> try
>> to get this attribute content back to the browser. Each time I get an
>> empty
>> result.
>> If I ask for the nodeName or node attribute, I get the required result.
>> It
>> only fails with nodeValue or data.
>>
>> Here's my flowscript, based on the link you sent to me. Hopefully you
>> know
>> what I'm doing wrong :
>> function getCaptchaUserEntry() {
>> // retrieve the XML
>> var xml = loadDocument("cocoon:/get-stream");
>> // get the root element:
>> var root = xml.getDocumentElement();
>> // get captcha elements (actually only 1 captcha element is allowed in
>> the
>> xforms)
>> var captchaUserEntries = root.getElementsByTagName("captcha");
>> // get captcha node
>> for (var i = 0; i < captchaUserEntries.getLength(); i++) {
>> var captchaUserEntry = captchaUserEntries.item(i);
>> }
>> // get required content
>> var captchaUserContent = captchaUserEntry.nodeValue;
>> // save in session - to debugg
>> var session = cocoon.session;
>> session.setAttribute("captcha-result", captchaUserContent);
>> // ---------------------------
>> var parameters = null;
>> parameters = {
>> "captcha-result": captchaUserContent,
>> };
>> cocoon.sendPage("check-session", parameters);
>> }
>> Thanks,
>> Josh
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
>
--
View this message in context:
http://www.nabble.com/How-to-get-same-function-as-java-loadDocument%28cocoon%3A-your.pipeline%29-in-javascript-flow--tf4581000.html#a13085727
Sent from the Cocoon - Users mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]