Hi Demian,

I tried it and it didn't work. I was trying to looking for simply solution and seems not it easy. 

I have ended up to add a function in VuFind.php which can do Explode and Map in the same time. Post it here it may use for others. 

    public static function explodeAndMap($delimiter, $string, $filename)
    {
        $parts = explode($delimiter, $string);
        $dom = new DOMDocument('1.0', 'utf-8');
        foreach ($parts as $part) {
            $element = $dom->createElement('part', mapString($part, $filename) );
            $dom->appendChild($element);
        }
        return $dom;
    }


Call the function from XSL Stylsheet.

<xsl:if test="//SBC[normalize-space()]">
                    <xsl:for-each select="//SBC[normalize-space()]">
                    <xsl:choose>
                        <xsl:when test="contains(., ', ')">
                                 <xsl:for-each select="php:function('VuFind::explodeAndMap', ', ', string(//SBC), 'sbc_map.properties')/part">
                                 <field name="genre_facet"><xsl:value-of select="normalize-space(string(.))" /></field>  
                                 </xsl:for-each>
                        </xsl:when>                   
                        <xsl:otherwise>
                               <field name="genre_facet">
    <xsl:value-of select="php:function('VuFind::mapString', normalize-space(string(.)), 'sbc_map.properties')"/>
                               </field>
                        </xsl:otherwise>
                     </xsl:choose>
                    </xsl:for-each>
                </xsl:if> 


Fang
Thanks,


On Wed, Apr 30, 2014 at 9:12 AM, Demian Katz <demian.katz@villanova.edu> wrote:

Ahh, I understand. Does it work if you wrap the mapString call around the normalize-space call in <field name="genre"><xsl:value-of select="normalize-space(string(.))" /</field>?

 

(My XSLT is not strong, so apologies if that’s a bad suggestion… if there doesn’t prove to be a simple way to accomplish this in native XSLT, you also have the option of creating a new custom PHP function that combines the two operations – I can provide instructions on how to do that if you need them, though hopefully it can be avoided!)

 

- Demian

 

From: Fang Peng [mailto:fang.peng@stonybrook.edu]
Sent: Tuesday, April 29, 2014 4:55 PM


To: Demian Katz
Cc: vufind-tech@lists.sourceforge.net
Subject: Re: XML index

 

Hi Demian,

Thank you for the info.

I knew about mapping function, Just don't know how to use two PHP functions (VuFind::explode'  and 'VuFind::mapString') in the same field. in my case in SBC (genre) fields. How to use mapstring in the following code. 

 

<xsl:if test="//SBC[normalize-space()]">

                    <xsl:for-each select="//SBC[normalize-space()]">

                     <xsl:choose>

                        <xsl:when test="contains(., ', ')">

                                 <xsl:for-each select="php:function('VuFind::explode', ', ', string(//SBC))/part">

                                   <field name="genre"><xsl:value-of select="normalize-space(string(.))" /</field>

                                  </xsl:for-each>

                        </xsl:when>                   

                        <xsl:otherwise>

                               <field name="genre">

                                   <xsl:value-of select="." />

                               </field>

                        </xsl:otherwise>

                     </xsl:choose>

                    </xsl:for-each>

                </xsl:if> 

 

On Tue, Apr 29, 2014 at 12:28 PM, Demian Katz <demian.katz@villanova.edu> wrote:

There is a PHP mapping function available in the XSL. Here is an example from the VuDL import script:

 

                    <xsl:if test="string-length($DC//dc:language[1]) > 0">

                        <field name="dc_language_str">

                            <xsl:value-of select="php:function('VuFind::mapString', normalize-space(string($DC//dc:language[1])), 'language_map_iso639-1.properties')"/>

                        </field>

                    </xsl:if>

 

Hopefully you can adapt this for your needs.

 

Regarding the stripping of the + character, what field type are you indexing the data into? Perhaps part of the Solr analysis chain is removing the character.

 

- Demian

 

From: Fang Peng [mailto:fang.peng@stonybrook.edu]
Sent: Tuesday, April 29, 2014 11:40 AM
To: Demian Katz
Cc: vufind-tech@lists.sourceforge.net
Subject: XML index

 

Hi All,

 

A field in the XML file to be indexed like 

<SBC> ARTS, CER, ESI, EXP+ </SBC>

Following XSL successfully indexed separately by ','.  

ARTS 

CER 

ESI 

EXP


But all are codes. How to add map file (  sbc_map.properties) in this? 

By the way, the index changed " EXP+" to " EXP" . Is it possible to keep the "+" in the index? 

 

Thanks for any suggestion.

 

Fang

 

          <xsl:if test="//SBC[normalize-space()]">

                    <xsl:for-each select="//SBC[normalize-space()]">

                     <xsl:choose>

                        <xsl:when test="contains(., ', ')">

                                 <xsl:for-each select="php:function('VuFind::explode', ', ', string(//SBC))/part">

                                   <field name="genre"><xsl:value-of select="normalize-space(string(.))" /</field>

                                  </xsl:for-each>

                        </xsl:when>                   

                        <xsl:otherwise>

                               <field name="genre">

                                   <xsl:value-of select="." />

                               </field>

                        </xsl:otherwise>

                     </xsl:choose>

                    </xsl:for-each>

                </xsl:if> 

                                             

 

 

 

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

Fang Peng

Information Systems Access Control Manager /DoIT

Stony Brook University 

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



 

--

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

Fang Peng

Information Systems Access Control Manager /DoIT

Stony Brook University 

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




--
************
Fang Peng
Information Systems Access Control Manager /DoIT
Stony Brook University 
************************