一区二区三区日韩精品-日韩经典一区二区三区-五月激情综合丁香婷婷-欧美精品中文字幕专区

分享

xml

 shineboy1 2015-10-28

Okay, so I'm having trouple with using javascript scripts to perform calculations on my XSLT transformation.

Basically, there is an xml element in the file to be transformed, with attributes startDateTime and endDateTime. All I want to do is subtract the two, and return that value for the user to see.

    <event startDateTime = "" endDateTime = "">    
      <eventOutcome>Fail</eventOutcome>
    <event>

Where obviously, everything would be filled in correctly. Then, there is an xslt transformation, that needs to do the math to find the elapsed time.

    <?xml version="1.0" encoding="utf-8"?>
    <xsl:stylesheet version="1.0"> //schemas included here

        <msxsl:script language="JScript" implements-prefix="user">
            function elapsedTime(start, end) {         
                return (xmlToDateTime(end).getTime() - xmlToDateTime(start).getTime()) / 1000;
            }

            function xmlToDateTime(xmlString) {
                //a script that works fine
            }
        </msxsl:script>

        <xsl:output method="xml" indent="yes"/>

        <xsl:template match="topLevelElement">
            <wordDocument>      
                 <body>
                    <sect>
                        <p>
                            <r>
                                <t><xsl:apply-templates select="event"/> Seconds</w:t>
                            </r>            
                        </p>          
                     <sect>
                <body>
            <wordDocument>
        </xsl:template>

        <xsl:template match="event">    
            <xsl:value-of select="user:elapsedTime(@startDateTime, @endDateTime)"/>    
        </xsl:template>

    </xsl:stylesheet>

What I want this to do is pass the attributes of event to the javascript function as strings. What it does instead, is pass an object of that Visual Studio identifies as {MS.Internal.Xml.XPathArrayIterator}. The function works fine if I use the strings directly like

<xsl:value-of select="user:elapsedTime(DATETIME', 'DATETIME')

So the problem isn't the javascript itself, but more my ability to send it arguments.

The official MS Documentation is less than helpful.

http://msdn.microsoft.com/en-us/library/533texsx(v=vs.110).aspx

For one, they use C# instead of JS, which I'm not sure the significance of. But they are just passing the name of an element in, no explanation of how it gets that value out.

I also read the FAQ here

http://www./xsl/sect4/N9745.html#d13958e70

And their code doesn't work! It gives the same issue of passing a {MS.Internal.Xml.XPathArrayIterator} instead of a value.

I'm at a loss here, so I'm open to any suggestions. Thanks in advance.

asked Jun 12 '14 at 1:35

1 Answer

up vote 2 down vote accepted

To pass string to a javascript function, you can use string function as : string(@startDateTime), string(@endDateTime)

answered Jun 12 '14 at 22:04
John Jin
894
    
Works perfectly. I haven't seen that suggestion anywhere. Thank you. – Russell_Rollins Jun 12 '14 at 22:44
1  
My pleasure. Also please be aware there is another scenario to pass string to js function: '{@startDateTime}', which is not for your case. – John Jin Jun 12 '14 at 22:56
    
Right. You cannot use AVT's inside of select attributes. That is a good general point though. – Russell_Rollins Jun 13 '14 at 15:55

    本站是提供個(gè)人知識管理的網(wǎng)絡(luò)存儲空間,所有內(nèi)容均由用戶發(fā)布,不代表本站觀點(diǎn)。請注意甄別內(nèi)容中的聯(lián)系方式、誘導(dǎo)購買等信息,謹(jǐn)防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請點(diǎn)擊一鍵舉報(bào)。
    轉(zhuǎn)藏 分享 獻(xiàn)花(0

    0條評論

    發(fā)表

    請遵守用戶 評論公約

    類似文章 更多

    欧美精品亚洲精品日韩精品| 在线亚洲成人中文字幕高清| 国内九一激情白浆发布| 亚洲国产成人精品福利| 国产成人精品99在线观看| 丁香七月啪啪激情综合| 欧美日韩综合综合久久久| 国产麻豆一线二线三线| 大屁股肥臀熟女一区二区视频 | 99久久精品午夜一区二| 亚洲一区二区三区在线中文字幕| 不卡一区二区高清视频| 国产不卡的视频在线观看| 亚洲一区二区三区在线免费| 成人免费在线视频大香蕉| 日本丁香婷婷欧美激情| 免费午夜福利不卡片在线 视频 | 亚洲一区精品二人人爽久久| 亚洲精品中文字幕无限乱码| 91插插插外国一区二区婷婷| 国产原创中文av在线播放| 中文字幕一区二区三区中文| 免费午夜福利不卡片在线 视频 | 日韩女优精品一区二区三区| 免费观看成人免费视频| 国产欧美性成人精品午夜| 国产一区欧美一区日韩一区 | 中文字幕一区二区三区大片| 久久99这里只精品热在线| 精品精品国产自在久久高清| 嫩草国产福利视频一区二区| 成人日韩在线播放视频| 九九热这里只有精品哦| 色一情一乱一区二区三区码| 日韩精品视频一二三区| 日本高清视频在线观看不卡| 久久精品国产亚洲av麻豆| 亚洲中文在线中文字幕91| 日本最新不卡免费一区二区| 东京热男人的天堂社区| 91亚洲精品亚洲国产|