[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: starts-with on more than one item

Subject: Re: starts-with on more than one item
From: David Carlisle <davidc@xxxxxxxxx>
Date: Tue, 27 May 2008 23:32:27 +0100
Re:  starts-with on more than one item
<xsl:for-each select="document('mySkus.xml')/skus">

there is only one item selected here, didn't you intend t iterate over
all the sku elements
<xsl:for-each select="document('mySkus.xml')/skus/sku">

<xsl:if test="starts-with('.', $skus)">

this is testing if the string "." contais anything saxon is telling you
the second parameter needs to be a single item but you presumably don't
want to test the string ".", you could test . which would select the
skus element but that is effectively your entire document 9ignoring all
markup) so I think you do want the for-each to go over skus/sku and then
to use . here to test each sku.
You could then use
to test if the current sku node starts aith any of the items in $sku.

(your input document is not well formed, which makes it harder to test
(--- in comments)

something like this:

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
 xmlns:xs="http://www.w3.org/2001/XMLSchema" exclude-result-prefixes="xs"
 version="2.0" >
<xsl:key name="sku" match="knowledge/part" use="code" />
<xsl:variable name="skus" as="xs:string*"
select="distinct-values(/knowledge/part/code)" />
<xsl:variable name="root" select="/"/>
<xsl:template match="/">
   <title>Test Document</title>
   <H1>Executive Summary</H1>
<p>Your proposal includes

    select="for $s in $skus return key('sku',$s[document('mySkus.xml')/skus/sku[starts-with(.,$s)]],$root)/name"
    separator=", "/>

$ saxon9 k.xml k.xsl
      <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
      <title>Test Document</title>
      <H1>Executive Summary</H1>
      <p>Your proposal includes
         Cisco phones, Cisco routers, Cisco switches

The Numerical Algorithms Group Ltd is a company registered in England
and Wales with company number 1249803. The registered office is:
Wilkinson House, Jordan Hill Road, Oxford OX2 8DR, United Kingdom.

This e-mail has been scanned for all viruses by Star. The service is
powered by MessageLabs. 

Current Thread


Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
First Name
Last Name
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.