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

starts-with on more than one item

Subject: starts-with on more than one item
From: "Ronnie Royston" <rhroyston@xxxxxxxxx>
Date: Tue, 27 May 2008 16:51:01 -0500
 starts-with on more than one item
Using Saxon-B 9.0 on Windows.  I have Wrox Beginning XML, Michael
Kay's XSLT 2.0 and XPATH 2.0, and Jeni Tennison's XSLT book and they
remind me how small my brain is.  I am new to XSL.

Here's what I have been trying to do (for 65 hours).  A little
background - I sell and install Cisco Systems gear - routers,
switches, firewalls, IP phones, etc.  I am building a "Scope of Work
Tool", an XSL Stylesheet, that is called from a file named
knowledge.xml (shown below) which inputs a simple xml file with the
document() function called 'myskus.xml' to determine what to output to
HTML.  Once I'm done, a customized Scope of Work (depending on what is
being sold, i.e., what is in myskus.xml) will be generated with the
click of a button.

Right now, I'm stuck trying to simply get started with this ambitious
endeavor.  All I am trying to do here is to output the <name> from
knowledge.xml for each sku in myskus.xml that starts-with the <code>
corresponding to the <name>.  So that the output html file says, "Your
proposal includes Cisco phones, Cisco routers, Cisco switches."
Putting an "and" before the last <name> is a different battle for a
different day.

myskus.xml looks like below and will differ based on each deal that I
sell - it's a list pf part numbers, or "sku's":

<?xml version="1.0"?>
<sku>CP-7937G</sku> <!--one flavor of Cisco phone-->
<sku>CP-7941G</sku> <!--another flavor of Cisco phone-->

OK, now for the xml file called knowledge.xml.  This has my
<knowledge> as the outermost element and <part> children.  The idea is
that each family of parts has specific verbiage that goes in to the
various phases of the installation process (the SOW), e.g., if the BOM
contains phones, we need the SOW to talk about how we <discovery>
determine the call forwarding parameters of each phone </discovery>
<stage>apply the decals to each phone and POST test each phone</stage>
<install> will place each phone at it's proper location and plug it in
to wall jack </install> <verify> will call to and from each phone to
ensure operation </verify>, etc.  The knowledge.xml file looks
something like this:

<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="testXsl.xsl"?>
        <code>CP-</code> <!--All Cisco phone part#'s begin with CP--->
        <name>Cisco phones</name>
        <discovery>call forwarding destinations</discovery>
        <verify>Out-dialing and In-dialing to a single phone in each
configured class of service ensures a working dialplan and handset
configuration.  </verify>
        <responsibility>unbox, assemble, and place phones at their
final locations</responsibility>
        <code>CISCO</code> <!--All Cisco router part#'s begin with CISCO--->
        <name>Cisco routers</name>
        <discovery>routing protocols to be enabled</discovery>
        <code>WS-C</code> <!--All Cisco Ethernet switches part#'s
begin with WS-C--->
        <name>Cisco switches</name>
        <discovery>VLAN assignments</discovery>
        <responsibility>connect all patch cords between switches and
patch panels</responsibility>

OK, Moving on (sorry for being verbose)...  I am stuck here - on the
style sheet, of course.  It's titled testXsl.xsl.  Below is what I've

<?xml version="1.0"?>
<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:template match="/">
   <title>Test Document</title>
   <H1>Executive Summary</H1>
<p>Your proposal includes
<xsl:for-each select="document('mySkus.xml')/skus">
<xsl:if test="starts-with('.', $skus)">
<xsl:value-of select="key('sku', '.')/name" />

Saxon tells me:
XPTY0004: A sequence of more than one item is not allowed as the
second argument of
  starts-with() ("CP-", "ATA186-", ...)
Transformation failed: Run-time errors were reported

I need to output <name> corresponding to <code> that starts-with <sku>
in myskus.xml.  Please help me.

Thank you for listening.

- Ronnie

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.