|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Using JavaScript to access <xml:list> items
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
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|

Cart








