Re: [xsl] NMTOKENS problem

Subject: Re: [xsl] NMTOKENS problem
From: "Eliot Kimber ekimber@xxxxxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Thu, 12 Feb 2015 20:26:03 -0000
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
bbbbb
Eliot Kimber, Owner
Contrext, LLC
http://contrext.com




On 2/12/15, 2:11 PM, "Craig Sampson craig.sampson@xxxxxxx"
<xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> 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 b<context b&>b output line commented out everything functions
>and I get two btoken: xxxb comments in the output file.
>  But when I uncomment the output line the transform fails to compile and
>I get an error message.
>  Ibve 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 wonbt see any responses
>till tomorrow unless you also CC me at:
>craig.sampson@xxxxxxx
>
>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 <>)

Current Thread