xsl-list
[Top] [All Lists]

RE: badly need xsl help

2003-10-13 09:01:49
Hi Rod,
        Thanks for your help. 
    But that is not what I exactly want. I store all my formatting info for my 
currency and date type data in global variables and call a bunch of functions 
later in the transformation to actually format the data. So
        <_Item>
                &lt;DecimalSymbol&gt;.&lt;/DecimalSymbol&gt;
                &lt;GroupingSymbol&gt;,&lt;/GroupingSymbol&gt;
                &lt;DigitGrouping&gt;2&lt;/DigitGrouping&gt;
        </_Item>

is just my debugging output I am producing to see what is going on in the 
javascript(in the transformation). So somehow, I have to get to each node in 
the currency and date to store that for later. By the way, I am using MSXML4.

thanks,
~Mur


-----Original Message-----
From: Rod Humphris - FLPTN 
[mailto:rod(_dot_)humphris(_at_)focusdiy(_dot_)co(_dot_)uk]
Sent: Monday, October 13, 2003 11:47 AM
To: 'xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com'
Subject: RE: [xsl] badly need xsl help


Hi Murali

If what you want is:

        <_Item>
                &lt;DecimalSymbol&gt;.&lt;/DecimalSymbol&gt;
                &lt;GroupingSymbol&gt;,&lt;/GroupingSymbol&gt;
                &lt;DigitGrouping&gt;2&lt;/DigitGrouping&gt;
        </_Item>

then why not throw away your JScript and use:

<xsl:template match="stat:Currency">
 <_Item>
  <xsl:apply-templates mode="Currency"/>
 </_Item>
</xsl:template>
        
<xsl:template match="node()" mode="Currency">
  &lt;<xsl:value-of select="name()"/>&gt;<xsl:value-of
select="."/>&lt;/<xsl:value-of select="name()"/&gt;
</xsl:template>

which gives you that.

Cheers

Rod


-----Original Message-----
From: Murali Korrapati [mailto:murali(_dot_)korrapati(_at_)reval(_dot_)com]
Sent: 13 October 2003 15:48
To: XSL-List(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: [xsl] badly need xsl help


Hi,
  I posted this question here before. But I didn't get any luck. So trying
again with some more details.

In this example, I can't access individual  nodes inside RegOptions in the
script.

xml:

<data xmlns="urn:schemas.abcd-com:layers">
        <Rpt_Inven xmlns="urn:schemas.abcd-com:RepInven" />
        <RegionalOptions xmlns="urn:schemas.abcd-com:Static">
                <Currency>
                        <DecimalSymbol>.</DecimalSymbol>
                        <GroupingSymbol>,</GroupingSymbol>
                        <DigitGrouping>2</DigitGrouping>
                </Currency>
                <Locale>1033</Locale>
                <Date>
                        <Calendar>
                        <TwoDigitYear>79</TwoDigitYear>
                        </Calendar>
                        <Separator>-</Separator>
                        <ShortFormat>3</ShortFormat>
                </Date>
        </RegionalOptions>
</data>


xsl :

<xsl:stylesheet version="1.0" xmlns=""
xmlns:lay="urn:schemas.abcd-com:layers"
xmlns:rep="urn:schemas.abcd-com:RepInven"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
xmlns:msxsl="urn:schemas-microsoft-com:xslt"
xmlns:scrdt="urn:schemas.abcd-com:datatypes" 
xmlns:stat="urn:schemas.abcd-com:Static">
        <xsl:output method="xml" encoding="UTF-8"/>
        <xsl:template match="lay:data">
                <_Ctrl>
                        <xsl:call-template name="callInit">
                                <xsl:with-param name="regOptNode"
select="stat:RegionalOptions"/>
                        </xsl:call-template>
                </_Ctrl>
        </xsl:template>
         <xsl:template name="callInit">
                <xsl:param name="regOptNode"/>
                <_Item>
                        <xsl:value-of select="scrdt:init($regOptNode)"/>
                </_Item>
        </xsl:template>
        <msxsl:script language="JScript" implements-prefix="scrdt"><![CDATA[

function init(RegOpts)
{
        if( !RegOpts.length) return "length 0";
        for( i = 0; i < RegOpts.length; i++ ) {
                xDate.init(RegOpts(i));
                xNumber.init(RegOpts(i));
                var val = RegOpts(i).selectSingleNode("Currency");
//              var val = RegOpts(i).firstChild;
                
                if(val!=null)
                        return val.xml;
        }
        return "End";
}
        ]]></msxsl:script>

</xsl:stylesheet>

    With this xml and xsl, I am expecting my out some thing like

<_Ctrl xmlns="" xmlns:lay="urn:schemas.abcd-com:layers"
xmlns:rep="urn:schemas.abcd-com:RepInven"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
xmlns:msxsl="urn:schemas-microsoft-com:xslt"
xmlns:scrdt="urn:schemas.abcd-com:datatypes" 
xmlns:stat="urn:schemas.abcd-com:Static">
        <_Item>
                &lt;DecimalSymbol&gt;.&lt;/DecimalSymbol&gt;
                &lt;GroupingSymbol&gt;,&lt;/GroupingSymbol&gt;
                &lt;DigitGrouping&gt;2&lt;/DigitGrouping&gt;
        </_Item>
</_Ctrl>

   But it is always producing something like 

   <_Ctrl xmlns="" xmlns:lay="urn:schemas.abcd-com:layers"
xmlns:rep="urn:schemas.abcd-com:RepInven"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
xmlns:msxsl="urn:schemas-microsoft-com:xslt"
xmlns:scrdt="urn:schemas.abcd-com:datatypes" 
xmlns:stat="urn:schemas.abcd-com:Static">
        <_Item>
                End
        </_Item>
</_Ctrl>


      I think this b'cos I am not able to get access to the <Currency/> node
in the script function. And whenever I say RegOpts(i).firstChild , I am
getting the result I want. 

Any ideas about. I am very desperate for this.

thanks,

~Mur




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


________________________________________________________________________
This email has been scanned for all viruses by the MessageLabs Email
Security System. For more information on a proactive email security
service working around the clock, around the globe, visit
http://www.messagelabs.com
________________________________________________________________________


________________________________________________________________
Any opinions expressed in this email are those of the individual and not 
necessarily the Company. Unless expressly stated to the contrary, this email is 
not intended to give rise to a new, or affect an existing, contractual or other 
legal relationship.This email and any files transmitted with it, including 
replies and forwarded copies which may contain alterations) subsequently 
transmitted from the Company, are confidential and solely for the use of the 
intended recipient. The unauthorised use, disclosure or copying of this email, 
or any other information contained or attached,is prohibited and could, in 
certain circumstances, be a criminal offence.

If you have received this email in error please notify the sender as soon as 
possible.

This footnote also confirms that this email message has been swept for the 
presence of computer viruses.

www.focusdiy.co.uk
_________________________________________________________________

________________________________________________________________________
This email has been scanned for all viruses by the MessageLabs Email
Security System. For more information on a proactive email security
service working around the clock, around the globe, visit
http://www.messagelabs.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



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