xsl-list
[Top] [All Lists]

RE: Interesting issue

2002-11-22 10:19:17
Mike,

Are you sure that the
contents of <lxslt:script> are not actually in a
CDATA section? 
Thanks for your time. I am sorry that was typo from my
end. I did have the CDATA section. 

There is a deeper question: what on earth inspired
you to try and solve this problem this way? It would
be much easier to do  it in pure XSLT, without any
Javascript, using the substring() function.

I have tried this too. The xml/xsl I sent are repro of
the real problem. I mean to say the <Customers>/<data>
contains more than 5000 bytes. So to process this big
string I didnt had any other option except using
Javascript. In actual the loop in the Javascript code
I sent executes 200 times.

If you think otherwise about my situation, I would
appreciate your valuable suggestions.

Thanks
Nischal



--- Michael Kay <michael(_dot_)h(_dot_)kay(_at_)ntlworld(_dot_)com> wrote:
I find it amazing that this does anything at all.
Are you sure that the
contents of <lxslt:script> are not actually in a
CDATA section? The
<Customers> element has no end tag, so the
stylesheet isn't well-formed
XML as written; and if that were corrected, I would
find it very
surprising if Xalan allowed the Javascript syntax
and the XML syntax to
cut across each other in this way.

If you put the script in a CDATA section, of course,
then the things
that look like tags just become ordinary character
data, and you end up
with a string that looks like unparsed XML - which
matches the behavior
you describe as "getting a string instead of a
node-list". Of course you
will get unparsed XML if you don't parse it.

There is a deeper question: what on earth inspired
you to try and solve
this problem this way? It would be much easier to do
it in pure XSLT,
without any Javascript, using the substring()
function.

Michael Kay
Software AG
home: Michael(_dot_)H(_dot_)Kay(_at_)ntlworld(_dot_)com
work: Michael(_dot_)Kay(_at_)softwareag(_dot_)com  

-----Original Message-----
From: owner-xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com 
[mailto:owner-xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com] On
Behalf Of 
Nischal Muthana
Sent: 22 November 2002 06:26
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: [xsl] Interesting issue


Hi All

I am transforming xml to xml using an xsl with
Xalan
XSLT processor. But I am getting the resulting xml
as
string instead of 

nodelist.

test.xsl
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
xmlns:lxslt="http://xml.apache.org/xslt"; 

xmlns:result="http://www.example.com/results";
extension-element-prefixes="result" version="1.0">
<xsl:output method="xml"/>
    <lxslt:component prefix="result"
functions="GetCopyBookData">
    <lxslt:script lang="javascript">
    function GetData(Data)
    {
            var x1 = 0;
            var x2 = 0;
            var result;
            for(var i = 1;i < 3; i++)
            {
                    var s = "<Customers><FirstName>";
                    x1 = x2;
                    x2 = x1 + 15;
                    s = s + Data.substring(x1,x2) + "</FirstName>";
                    s = s + "<LastName>";
                    x1 = x2;
                    x2 = x1 + 1;
                    s = s + Data.substring(x1,x2) + "</LastName>";
                    s = s + "<StreetNum>";
                    x1 = x2;
                    x2 = x1 + 1;
                    s = s + Data.substring(x1,x2) + "</StreetNum>";
                    s = s + "<Street>";
                    x1 = x2;
                    x2 = x1 + 1;
                    s = s + Data.substring(x1,x2) + "</Street>";
                    s = s + "<City>";
                    x1 = x2;
                    x2 = x1 + 1;
                    s = s + Data.substring(x1,x2) + "</City>";
                    s = s + "<State>";
                    x1 = x2;
                    x2 = x1 + 1;
                    s = s + Data.substring(x1,x2) + "</State>";
                    s = s + "<Zip>";
                    x1 = x2;
                    x2 = x1 + 1;
                    s = s + Data.substring(x1,x2) + "</Zip>";
                    result = result + s;
            }
            return result;
    }
    </lxslt:script>
    </lxslt:component>
    <xsl:template match="/">
            <xsl:variable name="Data" select="data"/>
            <xsl:value-of select="result:GetData($Data)"/>
    </xsl:template>
            
test.xml
<Customers> 


<data>SudhakarJalli030719751809Bigbenddrmilpitasca95035Rajeevk


asarabada032719751788lowerbenddrivesanjoseca94523</data>
</Customers>


Result.xml

<Customers>
    <FirstName>Sudhakar</FirstName>
    <LastName>Jalli</LastName>
    <DOB>03071975</DOB>
    <StreetNum>1809</StreetNum>
    <Street>BigBendDr</Street>
    <City>Milpitas</City>
    <State>CA</State>
    <Zip>95035</Zip>
</Customers>
    <FirstName>Rajeev</FirstName>
    <LastName>Kasarabada</LastName>
    <DOB>03271975</DOB>
    <StreetNum>1788</StreetNum>
    <Street>lowerbenddrive</Street>
    <City>sanjose</City>
    <State>CA</State>
    <Zip>94523</Zip>
</Customers>                

Thanks for your time
Nischal

__________________________________________________
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up
now. 
http://mailplus.yahoo.com

 XSL-List info and archive: 
http://www.mulberrytech.com/xsl/xsl-list



 XSL-List info and archive: 
http://www.mulberrytech.com/xsl/xsl-list



__________________________________________________
Do you Yahoo!?
Yahoo! Mail Plus ? Powerful. Affordable. Sign up now.
http://mailplus.yahoo.com

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list



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