[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

RE: [xsl] Value of element not returned


Subject: RE: [xsl] Value of <id> element not returned
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Mon, 4 Apr 2005 22:27:31 +0100

This is the output with Saxon:

<?xml version="1.0" encoding="UTF-8"?>
<root>
   <countMethod>
      <Name>1, Frisby, 48392</Name>
      <Name>10, Backstayge, 02718</Name>
      <Name>2, Attired, 00218</Name>
      <Name>300, McGoon, 27318</Name>
      <Name>31, Reckonwith, 02930</Name>
   </countMethod>
</root>

I think you've hit an Altova bug.

Michael Kay
http://www.saxonica.com/

 

> -----Original Message-----
> From: aspsa [mailto:aspsa@xxxxxxxxxxxxx] 
> Sent: 04 April 2005 20:35
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject: RE: [xsl] Value of <id> element not returned
> 
> Wendell,
> 
> Thanks for the reply. Below is the stylesheet and complete 
> XML document. I'm
> using the XSLT processor built into Altova's XMLSpy (Home 
> Edition, version
> 2005 sp2).
> 
> ====================
> 
> (stylesheet)
> 
> <?xml version="1.0" encoding="UTF-8"?>
> <xsl:stylesheet version="1.0"
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
>    <xsl:output method="xml" version="1.0" encoding="UTF-8" 
> indent="yes"/>
>    <xsl:key name="x" match="address" use="zip"/>
> 
>    <xsl:template match="/">
>      <root>
>        <countMethod>
>          <xsl:apply-templates mode="item-detail"
> select="addressbook/address[count(. | key('x', zip)[1])=1]"/>
>        </countMethod>
>      </root>
>    </xsl:template>
> 
>    <xsl:template match="address" mode="item-detail">
>      <Name>
>        <xsl:value-of select="id"/>
>        <xsl:text>, </xsl:text>
>        <xsl:value-of select="name/last-name"/>
>        <xsl:text>, </xsl:text>
>        <xsl:value-of select="zip"/>
>      </Name>
>    </xsl:template>
> 
> </xsl:stylesheet>
> 
> (XML document)
> 
> <?xml version="1.0" encoding="UTF-8"?>
> <addressbook>
>   <address>
>     <name>
>       <title>Mr.</title>
>       <first-name>Chester Hasbrouck</first-name>
>       <last-name>Frisby</last-name>
>     </name>
>     <street>1234 Main Street</street>
>     <city>Sheboygan</city>
>     <state>WI</state>
>     <zip>48392</zip>
>     <id>1</id>
>   </address>
>   <address>
>     <name>
>       <first-name>Mary</first-name>
>       <last-name>Backstayge</last-name>
>     </name>
>     <street>283 First Avenue</street>
>     <city>Skunk Haven</city>
>     <state>MA</state>
>     <zip>02718</zip>
>     <id>10</id>
>   </address>
>   <address>
>     <name>
>       <title>Ms.</title>
>       <first-name>Natalie</first-name>
>       <last-name>Attired</last-name>
>     </name>
>     <street>707 Breitling Way</street>
>     <city>Winter Harbor</city>
>     <state>ME</state>
>     <zip>00218</zip>
>     <id>2</id>
>   </address>
>   <address>
>     <name>
>       <first-name>Harry</first-name>
>       <last-name>Backstayge</last-name>
>     </name>
>     <street>283 First Avenue</street>
>     <city>Skunk Haven</city>
>     <state>MA</state>
>     <zip>02718</zip>
>     <id>20</id>
>   </address>
>   <address>
>     <name>
>       <first-name>Mary</first-name>
>       <last-name>McGoon</last-name>
>     </name>
>     <street>103 Bryant Street</street>
>     <city>Boylston</city>
>     <state>VA</state>
>     <zip>27318</zip>
>     <id>300</id>
>   </address>
>   <address>
>     <name>
>       <title>Ms.</title>
>       <first-name>Amanda</first-name>
>       <last-name>Reckonwith</last-name>
>     </name>
>     <street>930-A Chestnut Street</street>
>     <city>Lynn</city>
>     <state>MA</state>
>     <zip>02930</zip>
>     <id>31</id>
>   </address>
> </addressbook>
> ====================
> 
> 
> Thanks again.
> 
> 
> Respectfully,
> 
> ASP
> 
> 
> -----Original Message-----
> From: Wendell Piez [mailto:wapiez@xxxxxxxxxxxxxxxx]
> Sent: Monday, April 04, 2005 1:20 PM
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject: Re: [xsl] Value of <id> element not returned
> 
> 
> ASP,
> 
> Your code looks fine. It's not clear why you're not getting 
> the values,
> assuming everything in your source and stylesheet is as given.
> 
> All I can suggest is that you post again with a *complete* 
> sample input and
> stylesheet the demonstrates the problem (it's good for it to 
> be trimmed
> down, but it should be ready to run), which we can paste 
> somewhere and test.
> 
> It's also wise to tell us what processor you're using, etc., 
> although this
> particular problem doesn't look very likely to be a processor bug....
> 
> Cheers,
> Wendell
> 
> At 03:52 PM 4/3/2005, you wrote:
> >Hi, folks.
> >
> >I have the following stylesheet.
> >
> >=============================================================
> ==============
> =
> >===
> ><?xml version="1.0" encoding="UTF-8"?>
> ><xsl:stylesheet version="1.0"
> >xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
> >   <xsl:output method="xml" version="1.0" encoding="UTF-8" 
> indent="yes"/>
> >   <xsl:key name="x" match="address" use="zip"/>
> >
> >   <xsl:template match="/">
> >     <root>
> >       <countMethod>
> >         <xsl:apply-templates mode="item-detail"
> >select="addressbook/address[count(. | key('x', zip)[1])=1]"/>
> >       </countMethod>
> >     </root>
> >   </xsl:template>
> >
> >   <xsl:template match="address" mode="item-detail">
> >     <Name>
> >       <xsl:value-of select="id"/>
> >       <xsl:text>, </xsl:text>
> >       <xsl:value-of select="name/last-name"/>
> >       <xsl:text>, </xsl:text>
> >       <xsl:value-of select="zip"/>
> >     </Name>
> >   </xsl:template>
> >
> ></xsl:stylesheet>
> >
> >Here's a snippet of the XML document to be transformed.
> >
> ><?xml version="1.0" encoding="UTF-8"?>
> ><addressbook>
> >   <address>
> >     <name>
> >       <first-name>Mary</first-name>
> >       <last-name>Backstayge</last-name>
> >     </name>
> >     <street>283 First Avenue</street>
> >     <city>Skunk Haven</city>
> >     <state>MA</state>
> >     <zip>02718</zip>
> >     <id>10</id>
> >   </address>
> >... (etc) ...
> >=============================================================
> ==============
> =
> >===
> >
> >For some reason the value of <id> is not returned. Here's 
> the output, as it
> >reflects the entire XML source document.
> >
> ><?xml version="1.0" encoding="UTF-8"?>
> ><root>
> >   <countMethod>
> >     <Name>, Frisby, 48392</Name>
> >     <Name>, Backstayge, 02718</Name>
> >     <Name>, Attired, 00218</Name>
> >     <Name>, McGoon, 27318</Name>
> >     <Name>, Reckonwith, 02930</Name>
> >   </countMethod>
> ></root>
> >
> >Does anyone know why the <id> element values are not returned?
> 
> 
> ======================================================================
> Wendell Piez                            mailto:wapiez@xxxxxxxxxxxxxxxx
> Mulberry Technologies, Inc.                http://www.mulberrytech.com
> 17 West Jefferson Street                    Direct Phone: 301/315-9635
> Suite 207                                          Phone: 301/315-9631
> Rockville, MD  20850                                 Fax: 301/315-8285
> ----------------------------------------------------------------------
>    Mulberry Technologies: A Consultancy Specializing in SGML and XML
> ======================================================================


Current Thread
Keywords