[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: [string to node]

Subject: Re: [string to node]
From: Aditya Sakhuja <aditya.sakhuja@xxxxxxxxx>
Date: Sun, 21 Feb 2010 14:05:33 -0800
Re:  [string to node]
Specifically in XALAN-C processor.

On Sun, Feb 21, 2010 at 2:04 PM, Aditya Sakhuja
<aditya.sakhuja@xxxxxxxxx> 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="/">
> B <xsl:variable name="a">
> B  <xsl:choose>
> B  B <xsl:when test="1=1">
> B  B  B  B  <xsl:value-of select="//dd"/>
> B  B </xsl:when>
> B  </xsl:choose>
> B </xsl:variable>
> B <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@xxxxxxxxxxxxx> 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? B 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. B 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>
>>> B <xsl:when test="($tempPhone) and ($tempPhone!= 'Visit Web Site') and
>>> ($tempPhone!= 'All') and ($tempPhone!= 'A') and ($tempPhone!= 'B')">
>>> B  <xsl:value-of select="normalize-space($tempPhone)"/>
>>> B </xsl:when>
>>> B <xsl:otherwise>
>>> B  B <xsl:value-of select="//ads"/>
>>> B </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
>>
>>
>
>
>
> --
>
> -Cbib B%C%
>



--

-Cbib B%C%

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.