Hi there!

We have to match an element which is in 4 or 5 th level from the current
level.  Is there anyway to find out this element without giving the
absolute/relative path in the xsl?

For example, our XML file is as follows:

<cms:form>
        <cms:table>
                <cms:row>
                        <cms:cell>
                                <cms:input name="abc" value="1"/>
                        </cms:cell>
                </cms:row>

                <cms:row>
                        <cms:cell>
                                <cms:input name="xyz" value="2"/>
                        </cms:cell>
                </cms:row>
        </cms:table>
</cms:form>

In our stylesheet we have the following template:

<xsl:template match="cms:form">
                <xsl:apply-templates select='input'/>
                <xsl:if test="@submit">
                        <!--if the form has "submit" param, a submit button
is added with label equal to the value of "submit"-->
                        <do type="accept" label="{@submit}">
                                <go href="{@modpage}" method="post">
                                        <xsl:for-each select="input">
                                                <postfield name="{@item}"
value="$({@item})"/>
                                        </xsl:for-each>
                                </go>
                        </do>
                </xsl:if>
</xsl:template>

The above template works fine only if the <input> element is directly below
the <cms:form> tag.  It will not work if the <input> element is 2 or 3
levels below the <cms:form> tag.  We tried replacing the
"<xsl:apply-templates select='input'/>" line with
"<xsl:apply-templates select="//input"/>".  Even this did not work.  Any
suggestions?  

regards,
Hema.






-----Original Message-----
From: Martin Frost [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, July 18, 2001 6:03 PM
To: Hema Rajan
Subject: Re: Learning WML & WMLScript - reader question


Hema Rajan wrote:

> The converted WML file does not pass the value of the input
> elements to the next page.  The <postfield> tag should dynamically
> get the value from the <input> elements.  But this does not happen
> and it always takes the initial value of the input element.
> How can this problem be solved?

You have a problem with your stylesheet, in the lines that say:

        <!-- loop thru the input element and create a postfiled for each-->
        <xsl:for-each select="input">
                <postfield name="{@item}" value="{@value}"/>
        </xsl:for-each>

The <postfield> tag specification is incorrect. Doing it like that
will cause the XSL processor to insert the original value into
the WML file, and the WML browser will never see that it is supposed
to be anything other than the original value. (Look at the generated
WML: the value attribute has an empty string as its value.)

This line should actually read:

                <postfield name="{@item}" value="${@item}"/>

The XSL processor will expand this to, for example:

                <postfield name="foo" value="$foo"/>

and the WAP browser will then expand $foo at submit time.

Regards,

Martin




---------------------------------------------------------------------
Please check that your question has not already been answered in the
FAQ before posting. <http://xml.apache.org/cocoon/faqs.html>

To unsubscribe, e-mail: <[EMAIL PROTECTED]>
For additional commands, e-mail: <[EMAIL PROTECTED]>

Reply via email to