Subject: [xsl] Using JavaScript to access <xml:list> items From: "Hugh Dixon" <hugh.dixon@xxxxxxxxxxxxxx> Date: Wed, 17 Jul 2002 09:05:51 +1000 |
I've been looking around XML/XSL for a while now, but have done very little with it - so hopefully this will be trivial... I am interested in setting up a schema making much use of <xml:list> nodes, but am encountering problems accessing this data using xslt. I am interested in xml to xml transformations on windows clients - using microsoft tools ... Can someone please point me in the direction of information and examples on using/manipulating lists, as I suspect it is basic concept information I'm missing!!!! My current specific problem is (I think) a syntax thing. I have an XML file: <?xml version="1.0"?> <?xml-stylesheet type="text/xsl" href="ScriptTestQuest.xsl"?> <Root> <Lists> <List>1 3 4</List> <List>1 4 5</List> <List>5 3 1</List> </Lists> </Root> Which I am trying to transform with the xslt file: <?xml version="1.0"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/TR/WD-xsl" > <xsl:script language="javascript"> <![CDATA[ function car (e) { var strs = e.text.split(" "); return parseInt(strs[0]); } function contains(list, testValue) { var strs = list.text.split(" "); var elemCount = 0; while(elemCount <= (strs.length -1)){ if(parseInt(testValue) == parseInt(strs[elemCount])) return "Match"; elemCount = elemCount + 1; } return "No Match"; } function bContains(list, testValue) { var strs = list.text.split(" "); var elemCount = 0; while(elemCount <= (strs.length -1)){ if(parseInt(testValue) == parseInt(strs[elemCount])) return 1; elemCount = elemCount + 1; } return 0; } function cdr (e) { var strs = e.text.split(" "); var returnVal = " "; var elemCount = 2; if(strs.length > 1) returnVal = strs[1] else return ""; while(elemCount <= (strs.length -1)){ returnVal = returnVal + " " + strs[elemCount] elemCount = elemCount + 1; } return returnVal; } ]]> </xsl:script> <xsl:template match="List"> <xsl:eval>contains(this, 3)</xsl:eval> <xsl:eval>bContains(this, 3)</xsl:eval> <!-- This is the bit that confuses me--> <xsl:if test="bContains(this, 3)"> <BR/> Match!!! <BR/> </xsl:if> <BR/> </xsl:template> <xsl:template match="/"> Now The Lists (Init) <BR/> <xsl:apply-templates select = "Root/Lists/List"/> </xsl:template> </xsl:stylesheet> The line : <xsl:if test="bContains(this, 3)"> Is causing my problem. Could someone please explain the syntax I should use for this? Thanks!!! XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] Complete Extreme 2002 Program, B. Tommie Usdin | Thread | RE: [xsl] Using JavaScript to acces, Michael Kay |
Re: [xsl] XalanC++: 'Xalan' versus , James Fuller | Date | Re: [xsl] Re: Simple Replacement, ashu t |
Month |