473,396 Members | 2,092 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

XSLT: Transforming HTML Input Element's Values

Hi, I'm trying to transform the values entered into a form:

HTML:

<div id="container">
<div id="bs">
<input id="name" type="text"/>
<p>PPPPP</p>
<a href="#" onclick="return transform()">Do it!</a>
</div>
</div>

XSLT:

<xsl:template match="/">
<strong><xsl:value-of select="//input[@type='text']/@value"/></
strong>
--><xsl:value-of select="//p/text()"/>
</xsl:template>

Java Script:

function transform() {
....

xmlDoc = document.implementation.createDocument("", "", null);
xmlRef = document.getElementById('bs');

var clone = xmlDoc.importNode(xmlRef,true);
xmlDoc.appendChild(clone);

var fragment = xsltProcessor.transformToFragment(xmlDoc, document);

document.getElementById("container").innerHTML = "";
document.getElementById("container").appendChild(f ragment);

....
}

The <pelement gets transformed, but not the input element.
..
Now, I understand that I can pull the values out of the form with Java
Script and simply change the XPath expression to a XSLT param, but why
can't the transformation pull the values directly?

<input type="text" value="grr!"/will transform. Is the tree
structure for these two different? Humm, now that I think about it

document.getElementById('name').value

returns the value, whereas

document.getElementById('name').getAttribute('valu e')

returns null

Any explanations? Is it not possible to transform user supplied values
for input elements without passing the values into the style sheet as
parameters?

May 15 '07 #1
1 2398
MaggotChild wrote:
<input type="text" value="grr!"/will transform. Is the tree
structure for these two different? Humm, now that I think about it

document.getElementById('name').value

returns the value, whereas

document.getElementById('name').getAttribute('valu e')

returns null

Any explanations? Is it not possible to transform user supplied values
for input elements without passing the values into the style sheet as
parameters?
I do not think it is possible, @value is the attribute value which is
different from the value property of a control as the attribute value
does not change when someone enters text in the control. So the XSLT
processor or the XPath engine does only have access to the attribute
value, not the value property.
--

Martin Honnen
http://JavaScript.FAQTs.com/
May 15 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Pete | last post by:
I am just getting to grips with XML and I was wondering if you could help me with something that no-one seems able or willing to help with.. I have an XSLT file which should be transforming a...
2
by: Tom Corcoran | last post by:
I am working to ease updating of a html page by transforming 2 xml files. I was going to use xslt for this and had bought 2 unopened books, wrox xslt and o'reilly's xslt cookbook. But am now...
2
by: philips | last post by:
Hi everybody, I am using the Xalan 1.8 C++ API in a real-time financial application which need to apply XSLT transformations on XML input messages received on-the- fly. On the process output,...
0
by: Adam Retter | last post by:
Hi Guys, I have a need to create a html form based on my schema. I initially decided to do this using xql, have got some way but am finding this difficult (it may be as I am very new to xql)....
3
by: rush | last post by:
I have a DTD that defines new elements "mytextfield" and "mysn", and does it as an extension to XHTML. The idea is that my XML markup is actually valid XHTML according to my DTD. This all works...
4
by: David S. Alexander | last post by:
How can I do simple subtraction in an XSLT. I want to read a few attribute values from an XML document, calculate their difference, and transform that value to an attribute in the XML output...
3
by: Ian Roddis | last post by:
Hello, I want to embed SQL type queries within an XML data record. The XML looks something like this: <DISPLAYPAGE> <FIELD NAME="SERVER" TYPE="DROPDOWN"> <OPTION>1<OPTION> <OPTION>2<OPTION>...
0
by: shapper | last post by:
Hello, I am transforming a XML file into another XML file using a XSLT. Everything is working fine! I have only one problem: I want one of the values in my XSLT file to be taken from a Key...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.