xsl-list
[Top] [All Lists]

Re: [xsl] NMTOKENS problem

2015-02-12 14:26:09
Your error is the @eid reference on line 606:

<context contextMappingID="{.}" docset="{$alias}"
file="{$deliverable}.htm#{@eid}"/>


Because you're inside the for-each, the context item is a string, so the
reference to @eid can't be resolved.

You need to capture the value of @eid into a variable before the for-each
and then use that variable.

Cheers,

Eliot
—————
Eliot Kimber, Owner
Contrext, LLC
http://contrext.com




On 2/12/15, 2:11 PM, "Craig Sampson craig(_dot_)sampson(_at_)sas(_dot_)com"
<xsl-list-service(_at_)lists(_dot_)mulberrytech(_dot_)com> wrote:

Hi All,
 I am adding a template to one of my transforms that writes out an XML
navigation file in addition to the HTML files created by the transform.

 The DTD defines the softwareContextID attribute as NMTOKENS so that it
can contain one or more identified places in our software. I am using
tokenize to access each NMTOKEN in the attribute. When I run the program
(XSLT2 using SAXON EE)
with the “<context …>” output line commented out everything functions
and I get two “token: xxx” comments in the output file.
 But when I uncomment the output line the transform fails to compile and
I get an error message.
 I’ve included three scenarios below. Can anyone tell me what the
problem is and how to fix it?
Thanks,
 Craig

I follow this list using the digest mode, so I won’t see any responses
till tomorrow unless you also CC me at:
craig(_dot_)sampson(_at_)sas(_dot_)com

Snippet from XML input file:
<topic eid="p1lt7i0ekfifxnn0z4ph10m29vhl" helpID="about" onlineTOC="yes"
printTOC="yes" type="unassigned" xml:lang="en"
softwareContextID="craigabout000">
...
<subSubTopic eid="n0dpmvrz3i0s7gn18cvfhfdo7jr4"
helpID="subsubtopictest01" softwareContextID="craig005subsubtop
craig006subsubtop">

*******************************************************************

Try with tokenize being used to pick out the NMTOKEN's from the
softwareContextID attribute:
         <xsl:for-each select="subSubTopic">
           <xsl:if test="@softwareContextID">
             <xsl:for-each select="tokenize(@softwareContextID,' ')">
<!-- NMTOKENS -->
               <xsl:comment> token: <xsl:value-of
select="."/></xsl:comment>
               <xsl:if test="upper-case(.)!='DEFAULTLANDINGPAGE'">
line 606:         <context contextMappingID="{.}" docset="{$alias}"
file="{$deliverable}.htm#{@eid}"/>
               </xsl:if>
             </xsl:for-each> <!-- NMTOKEN -->
           </xsl:if>
         </xsl:for-each>  <!-- subSubTopic -->

FATAL SYNTAX ERROR::
Required item type of the context item for the attribute axis is node();
supplied value has item type xs:string
file:/C:/java/ide/eclipse/4.4/vert-i4xis15/eclipsedata/i4xis15/Publication
s.XmlInformationSystem.XisBuild/Source/
Stylesheets/eRoot.xsl, line 606 column -1


*******************************************************************

Try with variable "scID" declared as string:
         <xsl:for-each select="subSubTopic">
           <xsl:if test="@softwareContextID">
             <xsl:for-each select="tokenize(@softwareContextID,' ')">
<!-- NMTOKENS -->
               <xsl:variable name="scID" as="xs:string" select="."/>
<!-- treat NMTOKEN as string -->
               <xsl:comment> token: <xsl:value-of
select="$scID"/></xsl:comment>
               <xsl:if test="upper-case($scID)!='DEFAULTLANDINGPAGE'">
line 607:         <context contextMappingID="{$scID}" docset="{$alias}"
file="{$deliverable}.htm#{@eid}"/>
               </xsl:if>
             </xsl:for-each> <!-- NMTOKEN -->
           </xsl:if>
         </xsl:for-each>  <!-- subSubTopic -->

FATAL SYNTAX ERROR::
Required item type of the context item for the attribute axis is node();
supplied value has item type xs:string
file:/C:/java/ide/eclipse/4.4/vert-i4xis15/eclipsedata/i4xis15/Publication
s.XmlInformationSystem.XisBuild/Source/
Stylesheets/eRoot.xsl, line 607 column -1


*******************************************************************

Try with problem line commented out so the token comment will be written
out:
         <xsl:for-each select="subSubTopic">
           <xsl:if test="@softwareContextID">
             <xsl:for-each select="tokenize(@softwareContextID,' ')">
<!-- NMTOKENS -->
               <xsl:comment> token: <xsl:value-of
select="."/></xsl:comment>
               <xsl:if test="upper-case(.)!='DEFAULTLANDINGPAGE'">
                 <!-- context contextMappingID="{.}" docset="{$alias}"
file="{$deliverable}.htm#{@eid}"/ -->
               </xsl:if>
             </xsl:for-each> <!-- NMTOKEN -->
           </xsl:if>
         </xsl:for-each>  <!-- subSubTopic -->

Output:
<?xml version="1.0" encoding="UTF-8"?>
<contextMapping xmlns="http://www.w3.org/1999/xhtml";>
  <defaultContext docset="crsTestProject"
file="about.htm#p1s028tywy00run0zf1d2tyrkafa"/>
  <contexts>
     <context contextMappingID="craig001xyz"
              docset="crsTestProject"
              file="n070nvz1z69ek3n1jqzfc09i839y.htm"/>
     <context contextMappingID="craig002abc"
              docset="crsTestProject"
              file="p0ry6p2ed3rnthn1cz83qglec18i.htm"/>
     <context contextMappingID="craigabout000"
              docset="crsTestProject"
              file="about.htm"/>
     <!-- token: craig005subsubtop-->
     <!-- token: craig006subsubtop-->
     <context contextMappingID="craig002abcdef"
              docset="crsTestProject"
              file="p0jaax05zteg9an1j3iey30ni7g5.htm"/>
  </contexts>
</contextMapping>


XSL-List info and archive
<http://www.mulberrytech.com/xsl/xsl-list>EasyUnsubscribe
<-list/1278982>
(by email <>)


--~----------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
EasyUnsubscribe: http://lists.mulberrytech.com/unsub/xsl-list/1167547
or by email: xsl-list-unsub(_at_)lists(_dot_)mulberrytech(_dot_)com
--~--

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