473,948 Members | 17,317 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

I want to have an empty textarea

This is a piece of code from a xslt-file:

<xsl:template match="SMS">
<xsl:for-each select='.'>
<tr>
<td class = "inputDescripti on"><xsl:valu e-of select='.' />:</td>
<td><textarea class = "content" id = "{@id}" rows="5"
cols="50">#</textarea></td>
</tr>
</xsl:for-each>
</xsl:template>

When I remove the '#' to get an empty textare, the endtag is collapsed into
the begintag and all the HTML code after the textarea is displayed into the
textare. How can I get an empty textarea?

Feb 8 '07 #1
6 4069
On Feb 8, 11:23 pm, Cecil Westerhof <d...@dummy.nlw rote:
This is a piece of code from a xslt-file:

<xsl:template match="SMS">
<xsl:for-each select='.'>
As a side note, this is one of the silliest things I've
ever seen and a textbook case of magical thinking in
coding. It's not that I've never invoked foo to do bar
without understanding either foo or bar--I did, but after
being painfully bitten on my backside by that a few times
I just said no.
<tr>
<td class = "inputDescripti on"><xsl:valu e-of
select='.' />:</td>
<td><textarea class = "content" id = "{@id}"
rows="5" cols="50">#</textarea></td>
</tr>
</xsl:for-each>
</xsl:template>

When I remove the '#' to get an empty textare, the endtag
is collapsed into the begintag and all the HTML code
after the textarea is displayed into the textare. How can
I get an empty textarea?
You do get an empty textarea element, it is just being
serialized as XML. There are a few possible causes for
this:

- you might've forgotten to set <xsl:output method="html"
... /in your transformation. If this is the case, the
fix should be obvious.
- your XSLT processor doesn't grok <xsl:output method=
"html" ... /and blissfully serializes the resulting
tree as XML anyway. If this is the case, change your
XSLT processor.
- you're attempting to output XHTML1.0, but then serve it
as text/html anyway. Basically, XSLT processors couldn't
care less for workarounds described in W3C
recommendation to ensure backwards compatibility, and
without employing those workarounds you cannot serve
XHTML as text/html (and you shouldn't anyway if you care
for your sanity and general well-being one bit). If this
is the case, just output HTML4.01 instead (there might
be other solutions, but I won't go into that).

--
roy axenov

Feb 8 '07 #2
roy axenov wrote:
On Feb 8, 11:23 pm, Cecil Westerhof <d...@dummy.nlw rote:
>This is a piece of code from a xslt-file:

<xsl:template match="SMS">
<xsl:for-each select='.'>

As a side note, this is one of the silliest things I've
ever seen and a textbook case of magical thinking in
coding. It's not that I've never invoked foo to do bar
without understanding either foo or bar--I did, but after
being painfully bitten on my backside by that a few times
I just said no.
I am quite new to xml and xslt. (It is my first try.) So how should I'll do
this?
Any pointers what documentation to use to learn working with xml and xslt? I
have 'XML in a Nutshell', but that is mere for reference instead of
learning I think.
>
> <tr>
<td class = "inputDescripti on"><xsl:valu e-of
select='.' />:</td>
<td><textarea class = "content" id = "{@id}"
rows="5" cols="50">#</textarea></td>
</tr>
</xsl:for-each>
</xsl:template>

When I remove the '#' to get an empty textare, the endtag
is collapsed into the begintag and all the HTML code
after the textarea is displayed into the textare. How can
I get an empty textarea?

You do get an empty textarea element, it is just being
serialized as XML. There are a few possible causes for
this:

- you might've forgotten to set <xsl:output method="html"
... /in your transformation. If this is the case, the
fix should be obvious.
This shall be it. I did not know about this. I need to go now, but when I
come back, I'll look it up.

Feb 9 '07 #3
On Feb 9, 8:00 am, Cecil Westerhof <d...@dummy.nlw rote:
roy axenov wrote:
On Feb 8, 11:23 pm, Cecil Westerhof <d...@dummy.n l>
wrote:
This is a piece of code from a xslt-file:
<xsl:template match="SMS">
<xsl:for-each select='.'>
As a side note, this is one of the silliest things I've
ever seen and a textbook case of magical thinking in
coding. It's not that I've never invoked foo to do bar
without understanding either foo or bar--I did, but
after being painfully bitten on my backside by that a
few times I just said no.

I am quite new to xml and xslt. (It is my first try.) So
how should I'll do this?
Well, you just don't need that for-each. It doesn't really
do anything. As to why you don't need it: the first step is
understanding what for-each really is in XSLT. It's not a
'loop' - there are no loops in XSLT, - it's an inline
template together with its application to a nodeset. That
is:

<xsl:template match="foo">
<xsl:for-each select="bar">
<template/>
</xsl:for-each>
</xl:template>

....is almost-equivalent to:

<xsl:template match="foo">
<xsl:apply-templates select="bar"
mode="absolutel y-globally-unique-mode"/>
</xsl:template>

<xsl:template match="@*|node( )"
mode="absolutel y-globally-unique-mode">
<template/>
</xsl:template>

Not try translating your code into this template-based
form:

<xsl:template match="SMS">
<xsl:apply-templates select="."
mode="absolutel y-globally-unique-mode"/>
</xsl:template>

<xsl:template match="@*|node( )"
mode="absolutel y-globally-unique-mode">
<!-- whatever goes into the for-each -->
</xsl:template>

Now the flaw should be obvious. The first template
doesn't do anything, except invoking another template with
the same context node. Note that the template invoked is
guaranteed to always match, and not to be invoked by any
other template (otherwise this construct might make sense
under some circumstances).
Any pointers what documentation to use to learn working
with xml and xslt? I have 'XML in a Nutshell', but that
is mere for reference instead of learning I think.
References are good (although I've no idea if the one
you've mentioned *is* good). The group regulars will
probably have some good books to recommend, but in my
opinion the best way to learn is learning by doing and
understanding. With one caveat: don't try that in
production environments. Reading comp.text.xml and trying
to solve other people's problems is an excellent way to
learn.

XSL FAQ (google it) is an excellent if somewhat poorly
organized reading.

Just one hint: if you come from imperative programming
background, you'll need a paradigm shift. Until you learn
by heart that XSLT is a functional, template-based
language, you won't be any good at using it efficiently.

--
Pavel Lepin

Feb 9 '07 #4
p.*****@ctncorp .com wrote:
>I am quite new to xml and xslt. (It is my first try.) So
how should I'll do this?

Well, you just don't need that for-each. It doesn't really
do anything. As to why you don't need it: the first step is
understanding what for-each really is in XSLT. It's not a
'loop' - there are no loops in XSLT, - it's an inline
Well I removed all the for-each and I did not see any difference. ;-}
I do not understand your explanation, but maybe when I take the time to
comprehend it ...

Why did the make the for-each when it is not usefull?

>Any pointers what documentation to use to learn working
with xml and xslt? I have 'XML in a Nutshell', but that
is mere for reference instead of learning I think.

References are good (although I've no idea if the one
you've mentioned *is* good). The group regulars will
probably have some good books to recommend, but in my
opinion the best way to learn is learning by doing and
understanding. With one caveat: don't try that in
production environments. Reading comp.text.xml and trying
to solve other people's problems is an excellent way to
learn.
Expect to get a lot of questions in the newsgroup.
I must say that it is easy to get started with it. You can get transforming
xml to (inner) html quit fast. But the finer points will need time I am
afraid. :-}

XSL FAQ (google it) is an excellent if somewhat poorly
organized reading.
I'll look.

Feb 9 '07 #5
roy axenov wrote:
>When I remove the '#' to get an empty textare, the endtag
is collapsed into the begintag and all the HTML code
after the textarea is displayed into the textare. How can
I get an empty textarea?

You do get an empty textarea element, it is just being
serialized as XML. There are a few possible causes for
this:

- you might've forgotten to set <xsl:output method="html"
... /in your transformation. If this is the case, the
fix should be obvious.
- your XSLT processor doesn't grok <xsl:output method=
"html" ... /and blissfully serializes the resulting
tree as XML anyway. If this is the case, change your
XSLT processor.
I did not use xsl:output, but using it only complicated things. It made all
the tags uppercase and even added some tags. But the textarea kept being
generated the xml way. This was when using the firefox browser as
xslt-processor. When the processing is done on the server there is no
problem. But I like the processing to be done in the browser.
I decided to just use a '#' as a placeholder when I need an empty textarea
and delete the '#' with javascript. The only problem with this is that I
can not have a textarea filled with only a '#', but I think I can live with
that. :-}

Feb 9 '07 #6
Cecil Westerhof wrote:
I do not understand your explanation, but maybe when I take the time to
comprehend it ...
Part of the problem is that Pavel gave you a slightly over-theoretical
explanation. It's correct, but not the information you really needed
right at this time.
Why did the make the for-each when it is not useful?
It is useful... when there's actually more than one node to iterate
over. The sloppiness in your example is that <xsl:for-each select=".">,
in specific, is a no-op. "Process all instances of 'the current node'"
is the same as just going ahead and processing the current node.
For-each is useful when you want to gather and process _multiple_
nodes/values.

In many cases, it actually is better to use an apply-templates call and
additional templates rather than a for-each. Learning when to use each
of those techniques is something that comes with experience.

--
() ASCII Ribbon Campaign | Joe Kesselman
/\ Stamp out HTML e-mail! | System architexture and kinetic poetry
Feb 9 '07 #7

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

Similar topics

6
2385
by: lawrence | last post by:
I've the form you see below, which is supposed to upload an image. I expect the image name as a var to be $uploadedFile. In the receiving function, I've this code: global $uploadedFile, $uploadedFile_size, $uploadedFile_name; echo "here is the file name: $uploadedFile, $uploadedFile_size, $uploadedFile_name; <hr> "; $uploadedFile_name = $formatTextObject->processFileName($uploadedFile_name); $uploadedFile_name =...
4
3502
by: Kevin | last post by:
I am having problems in my php code. I am relatively new to php but I know some basics. This is the problem: when i try to echo some information that is typed into form back to the screen i get absolutely nothing. It seems like $_POST is an empty string, along with $_POST and $_GET. I looked around to see if someone else had the same problem and found
3
6197
by: Gadrin77 | last post by:
I noticed when displaying the contents of a CDATA node inside a TEXTAREA using MSXML and XSL, I get an extra space before the data. at first I thought I hadn't "tightened up" the XSL, but then even when I did this... <textarea rows="24" cols="80"><xsl:value-of select="/Root/Child/Data"/></textarea>
4
5285
by: Simon | last post by:
I have another question.. Let's take a textarea with the parameter: "rows=4" (<textarea rows=4 onkeydown="CheckScrollbar()"> ) If you start typing the scrollbar at the right is not active. Only when you exceed the four lines (rows=4) the scrollbar becomes active. That moment..the moment the scrollbar becomes active..can javascript recognize/capture this moment? Thanks, Simon
6
6002
by: wperry1 | last post by:
I am writing a small database utility to catalog all of my favorite ASM/JS/VBS... functions and scripts on an asp page. Everything is going smoothly except for one thing that I can't quite seem to think my way around. I am using a <textarea> to display the code but some of my scripts have <textarea> tags in them and when the </textarea> tag is entered, it closes my <textarea> and the rest of the code ends up outside of the textarea.
0
1117
by: gnotev | last post by:
Hi look at this code, it gets a record and prints the column values: $rs = $conn->Execute("SELECT * FROM products WHERE ID = ".$_GET); $id = $rs->Fields("ID"); $nm = $rs->Fields("name"); $ds = $rs->Fields("desc"); $ct = $rs->Fields("cat"); $tt = $rs->Fields("title"); $pp = $rs->Fields("picpath"); echo...
7
3367
by: Xh | last post by:
Hi All, I have problems with generating valid HTML output there are few HTML elements that i don't what to output as <tagname/> but as <tagname></tagnamebut Xalan keeps generating them as <tagname/> there are few really annoying situations where adding   to some HTML elements is necessary:
5
1873
by: Jan Danielsson | last post by:
Hello all, I'm using mod_python+ElementTree to build XHTML pages. But I stumbled across this problem: -------------------- def foo(req, desc = None): ...
4
3067
by: wizardry | last post by:
hello - i've created a form that has multiple inserts. it inserts the data fine if i manually parse the data to it but when i use the form to test the inserts it errors out. it errors out at the title/comments table. the 2 tables before are inserted fine. i've used echo $_post variable and the variable is their. but its not being inserted into the database. ...
0
11582
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
11355
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10695
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9898
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
8257
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
7432
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
6340
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4949
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
4543
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.