xsl-list
[Top] [All Lists]

RE: xsl:attribute vs "expected comment or PI"?

2006-01-22 09:05:51
This is the result I get using the Saxon 8.6 processor:

<?xml version="1.0" encoding="UTF-8"?>
<ul xmlns:fmp="http://www.filemaker.com/fmpxmlresult";>
   <li>
      <a href="authors-A.html" title="18 authors,15 articles">18</a>
   </li>
   <li>
      <a href="authors-B.html" title="18 authors,15 articles">18</a>
   </li>
</ul>

Is this what you expect? This is my stylesheet (note all the attribute content 
is on one line to prevent insertion of spacing characters not wanted):

<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"; 
xmlns:fmp="http://www.filemaker.com/fmpxmlresult";>
  <xsl:output method="xml" indent="yes" />
  <xsl:strip-space elements="*" />

  <xsl:template match="fmp:FMPXMLRESULT">
    <ul>
      <xsl:for-each select="fmp:RESULTSET/fmp:ROW">
       <li>
        <a>
         <xsl:attribute name="href">authors-<xsl:value-of 
select="fmp:COL[1]/fmp:DATA[1]"/>.html</xsl:attribute>
         <xsl:attribute name="title"><xsl:value-of 
select="fmp:COL[2]/fmp:DATA[1]"/> author<xsl:if 
test="fmp:COL[2]/fmp:DATA[1]!='1'">s</xsl:if>,<xsl:value-of 
select="fmp:COL[3]/fmp:DATA[1]"/> article<xsl:if 
test="fmp:COL[3]/fmp:DATA[1]!='1'">s</xsl:if></xsl:attribute>
         <xsl:value-of select="fmp:COL[2]/fmp:DATA[1]"/>
        </a>
       </li>
      </xsl:for-each>
    </ul>
  </xsl:template>
    
</xsl:stylesheet>

If this is what you expect, then your problem is with your XSLT transformer, 
not your code.
-- 
Charles Knell
cknell(_at_)onebox(_dot_)com - email



-----Original Message-----
From:     Eric Scheid <eric(_dot_)scheid(_at_)ironclad(_dot_)net(_dot_)au>
Sent:     Mon, 23 Jan 2006 02:24:01 +1100
To:       "xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com" 
<xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com>
Subject:  [xsl] xsl:attribute vs "expected comment or PI"?

I'm baffled. Why is this not working? The error I'm getting is "expected
comment or processing instruction". The problem is somewhere within the
second xsl:attribute ... if I take it out, no error. I've tried switching
the two xsl:attributes around, I've tried jamming it all onto one line, I've
tried taking the other xsl:attribute out ... no luck.

<xsl:template match="fmp:FMPXMLRESULT">
<ul>
<xsl:for-each select="fmp:RESULTSET/fmp:ROW">
 <li>
  <a>
   <xsl:attribute name="href">authors-<xsl:value-of
select="fmp:COL[1]/fmp:DATA[1]"/>.html</xsl:attribute>
   <xsl:attribute name="title">
    <xsl:value-of select="fmp:COL[2]/fmp:DATA[1]"/> author
    <xsl:if test="fmp:COL[2]/fmp:DATA[1]!='1'">s</xsl:if>,
    <xsl:value-of select="fmp:COL[3]/fmp:DATA[1]"/> article
    <xsl:if test="fmp:COL[3]/fmp:DATA[1]!='1'">s</xsl:if>
   </xsl:attribute>
   <xsl:value-of select="fmp:COL[2]/fmp:DATA[1]"/></a></li>
</xsl:for-each>
</ul>
</xsl:template>

The input data looks like this:

<FMPXMLRESULT xmlns="http://www.filemaker.com/fmpxmlresult";>
<RESULTSET FOUND="345">
<ROW MODID="6" RECORDID="24">
    <COL><DATA>A</DATA></COL>
    <COL><DATA>18</DATA></COL>
    <COL><DATA>15</DATA></COL>
</ROW>
<ROW MODID="6" RECORDID="25">
    <COL><DATA>B</DATA></COL>
    <COL><DATA>18</DATA></COL>
    <COL><DATA>15</DATA></COL>
</ROW>
</RESULTSET>
</FMPXMLRESULT>


--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--




--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--



<Prev in Thread] Current Thread [Next in Thread>