xsl-list
[Top] [All Lists]

Re: [xsl] [string to node]

2010-02-21 16:05:57
Specifically in XALAN-C processor.

On Sun, Feb 21, 2010 at 2:04 PM, Aditya Sakhuja
<aditya(_dot_)sakhuja(_at_)gmail(_dot_)com> wrote:
Hi,

So, my objective is to get the count() function to count the number of
'dd' elements.

test.xsl

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" 
xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
<xsl:output method="xml" encoding="UTF-8"/>

<xsl:template match="/">
 <xsl:variable name="a">
  <xsl:choose>
   <xsl:when test="1=1">
        <xsl:value-of select="//dd"/>
   </xsl:when>
  </xsl:choose>
 </xsl:variable>
 <xsl:value-of select="count($a)"/>
</xsl:template>
</xsl:stylesheet>


test.xml

<a>
<dd/>
<dd/>
<dd/>
</a>

Cheers!
Aditya

On Fri, Feb 19, 2010 at 11:33 PM, ac <ac(_at_)hyperbase(_dot_)com> wrote:
Hi Aditya,

You declare "test-phone" but only use "temp-phone" so I assume that this is
a typo.

You do not initialize it either, so I will assume that it holds a string.

What kind of node are you trying to convert your string to, element,
attribute, text? Why?

Your code does not use count() so I am trying to guess how you hope to use
it ...

What is it that you are trying to count?  a string is atomic so there is
one.

If you are looking for the number of characters that the string has, you
could use string-length($temp-phone).

If the string is tokenizable and you wish to count the tokens, you should
probably tokenize it first, somehow. How are tokens defined?

We may need more information on what you are trying to do to have a chance
of better helping you.  At least I do.

Cheers,
ac


Hello,

I am looking to convert a string to a single node type. Using Xalan C
1.10 processor.

for eg:

<xsl:variable name="test-phone">
<xsl:choose>
 <xsl:when test="($tempPhone) and ($tempPhone!= 'Visit Web Site') and
($tempPhone!= 'All') and ($tempPhone!= 'A') and ($tempPhone!= 'B')">
  <xsl:value-of select="normalize-space($tempPhone)"/>
 </xsl:when>
 <xsl:otherwise>
   <xsl:value-of select="//ads"/>
 </xsl:otherwise>
</xsl:choose>
</xsl:variable>

What I have in test-phone is a string. on which I cannot use
count($test-phone).

What is the best way to have the count() ? I am trying to get a node
from the string, that would work.

Thanks in advance,
Aditya Sakhuja

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or 
e-mail:<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--




--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: 
<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--





--

-Å∂i†¥å




-- 

-Å∂i†¥å

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>