0

I keep receiving this error message

Required attribute 'select' is missing.

I already used this code before and it was working fine, but it seems that it is not applicable to

<xsl:output method="text" />

Hope you can help me.

 <?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
    xmlns:wd="urn:com.workday.report/Sample_Outbound">

    <xsl:output method="text" />
            <xsl:variable name="linefeed" select="'&#xA;'"></xsl:variable>
            <xsl:variable name="StreetAddress1">Street Address 1</xsl:variable>

    <xsl:template match="wd:Report_Data">
        <File>
            <!-- Header -->
            <Header>
                <StreetAddress1>
                    <xsl:value-of select="$StreetAddress1" />
                </StreetAddress1>
                <xsl:value-of select="$linefeed" />
            </Header>

            <xsl:for-each select="wd:Report_Entry">
                <Record>
                    <Work_Street_Address_1>
                        <xsl:call-template name="Remove-Special-Characters-Commas">
                        <xsl:with-param name="normalize-string"
                             select="wd:Work_Street_Address_1"  />
                        </xsl:call-template>
                    </Work_Street_Address_1>

                    <xsl:value-of select="$linefeed" />
                </Record>
            </xsl:for-each>
        </File>
    </xsl:template>

    <xsl:template name="Remove-Special-Characters-Commas">
        <xsl:param name="normalize-string" />
        <xsl:variable name="AllowedSymbols"
            select="'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-.,#():@/;\'&apos;_&amp;'" />
        <xsl:variable name="stringValuePreformatted"
            select="translate($normalize-string,'àâäèéêëîïôœùûüÿÀÁÄÈÉÊËÎÏÔŒÙÛÜŸçÇáéíóúÁÉÍÓÚäöüÄÖÜßàèéìòóùÀÈÉÌÒÓÙáéíóúüÁÉÍÓÚÜñÑ¿¡','aaaeeeeiioeuuuYAAAEEEEIIOEUUUYCCaeiouAEIOUaouAOUBaeeioouAEEIOOUaeiouuAEIOUUnN?1')" />
        <xsl:value-of
            select="normalize-space(translate($stringValuePreformatted, translate($stringValuePreformatted, $AllowedSymbols,''),''))" />
    </xsl:template>

</xsl:stylesheet>

The line error is

line 39: Error parsing XPath expression ''abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-.,#():@/;\''_&''.
line 39: Required attribute 'select' is missing.

enter code here

Thanks

FG Munoz
  • 1
  • 1
  • 2

3 Answers3

-1

Replace your line

<xsl:variable name="AllowedSymbols" select="'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-.,#():@/;\'&apos;_&amp;'" /> 

by

<xsl:variable name="apos">'</xsl:variable>
<xsl:variable name="AllowedSymbols" select="concat('abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-.,#():@/;_\&amp;',$apos)" />

and everything should work as expected.
In this approach I used this SO answer for handling the ' situation by using a variable.

Community
  • 1
  • 1
zx485
  • 28,498
  • 28
  • 50
  • 59
-1

The source of your problem is &apos;. Replace it with 2 apostrophes.

Valdi_Bo
  • 30,023
  • 4
  • 23
  • 41
-1

The simplest way to solve the problem is to change the definition of the variable from:

<xsl:variable name="AllowedSymbols"
       select="'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-.,#():@/;\'&apos;_&amp;'" />

to:

<xsl:variable name="AllowedSymbols">abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-.,#():@;&apos;_&amp;</xsl:variable>

Alternatively, you could switch the single and double quotes around like this:

<xsl:variable name="AllowedSymbols"
       select='"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-.,#():@;&apos;_&amp;"'/>

but then you won't be able to add a double quote to the list.

michael.hor257k
  • 113,275
  • 6
  • 33
  • 51