Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: I want to have an empty textarea

From: p.lepin@-------.---
To: NULL
Date: 2/9/2007 12:15:00 AM

On Feb 9, 8:00 am, Cecil Westerhof <d...@dummy.nl> wrote:
> roy axenov wrote:
> > On Feb 8, 11:23 pm, Cecil Westerhof <d...@dummy.nl>
> > 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="absolutely-globally-unique-mode"/>
  </xsl:template>

  <xsl:template match="@*|node()"
    mode="absolutely-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="absolutely-globally-unique-mode"/>
  </xsl:template>

  <xsl:template match="@*|node()"
    mode="absolutely-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



transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent