Hi Luke, hi all!

 

It took several trials because it’s been a while since I’ve dealt with this kind of stuff, but it all came back to me for a last attempt, working one, when stopped for a second and tried to remember how namespaces in XSLT work (basically I would say it works like arguments being passed and invoked inside functions or at least is the perception that I have from a trial-error basis knowledge acquired).

 

And here you go:

 

----

 

<!-- available fields are defined in solr/biblio/conf/schema.xml -->

<xsl:stylesheet version="1.0"

    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"

    xmlns:php="http://php.net/xsl"

    xmlns:a="http://info.internet.isi.edu:80/in-notes/rfc/files/rfc1807.txt">

    <xsl:output method="xml" indent="yes" encoding="utf-8"/>

    <xsl:param name="institution">Swansea University</xsl:param>

    <xsl:param name="collection">RIS</xsl:param>

    <xsl:template match="a:rfc1807">

        <add>

            <doc>

                <field name="id">

                    <xsl:value-of select="a:id"/>

                </field>

             </doc>

        </add>

    </xsl:template>

</xsl:stylesheet>

 

---

 

xmlns:a could be xmlns:xpto, xmlns:xpto :) or whatever:

 

---

 

<!-- available fields are defined in solr/biblio/conf/schema.xml -->

<xsl:stylesheet version="1.0"

    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"

    xmlns:php="http://php.net/xsl"

    xmlns:xpto="http://info.internet.isi.edu:80/in-notes/rfc/files/rfc1807.txt">

    <xsl:output method="xml" indent="yes" encoding="utf-8"/>

    <xsl:param name="institution">Swansea University</xsl:param>

    <xsl:param name="collection">RIS</xsl:param>

    <xsl:template match="xpto:rfc1807">

        <add>

            <doc>

                <field name="id">

                    <xsl:value-of select="xpto:id"/>

                </field>

             </doc>

        </add>

    </xsl:template>

</xsl:stylesheet>

 

--- the output will be:

 

 

<?xml version="1.0" encoding="utf-8"?>

<add xmlns:php="http://php.net/xsl" xmlns:xpto="http://info.internet.isi.edu:80/in-notes/rfc/files/rfc1807.txt">

  <doc>

    <field name="id">9</field>

  </doc>

</add>

 

--- and better yet:

 

Successfully imported test.xml...

 

All the best (“write to you” later, next DC, if not before),

 

Filipe

____________________________________________

Filipe Manuel S. Bento  |  http://about.filipebento.pt/

ICPD Doctorate Candidate (UA | U.Porto) * PhD Researcher (UA/CETAC.Media), grant by FCT - Portuguese Foundation for Science and Technology

Chairman of USE.pt Management Board (Portuguese Ex Libris Users’ National Association, hosted by Portuguese Parliament, Palácio de S. Bento, Lisbon, http://www.USEpt.org)

 

 

From: Osullivan L. [mailto:L.Osullivan@swansea.ac.uk]
Sent: quinta-feira, 28 de Fevereiro de 2013 14:20
To: vufind-tech@lists.sourceforge.net
Subject: [VuFind-Tech] OAI / XSL

 

Hi Folks,

I'm trying to ingest some xml files obtained via OAI and I'm running into a few problems with the xsl tranformations.

The xml is quite simple:

<rfc1807 xmlns="http://info.internet.isi.edu:80/in-notes/rfc/files/rfc1807.txt" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://info.internet.isi.edu:80/in-notes/rfc/files/rfc1807.txt http://www.openarchives.org/OAI/1.1/rfc1807.xsd">
          <bib-version>v2</bib-version>
          <id>9</id>
          <entry>2011-10-01</entry>
          <title>Write now!</title>
          <author>Harold Thimbleby</author>
          <date>2011-10-01</date>
</rfc1807>

And here is the xsl:

<!-- available fields are defined in solr/biblio/conf/schema.xml -->
<xsl:stylesheet version="1.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:php="http://php.net/xsl"
    xmlns:rfc1807="http://info.internet.isi.edu:80/in-notes/rfc/files/rfc1807.txt">
    <xsl:output method="xml" indent="yes" encoding="utf-8"/>
    <xsl:param name="institution">Swansea University</xsl:param>
    <xsl:param name="collection">RIS</xsl:param>
    <xsl:template match="/">
        <add>
            <doc>
                <field name="id">
                    <xsl:value-of select="id"/>
                </field>
             </doc>
        </add>
    </xsl:template>
</xsl:stylesheet>

For some reason, <xsl:template match="rfc1807"> results in an outputted file with all the text but none of the tags (even <add> and <doc> are missing. I have tried using //id as the selector but that doesn't work either. The only way I can get it to work is to remove the xmlns from the <rfc1807> root element in the xml file.

Can anyone offer any pointers?

Cheers,

Luke

-- 
Luke O'Sullivan
Systems Developer
Web Team
Swansea University, Singleton Park, Swansea SA2 8PP, UK
l.osullivan@swansea.ac.uk
01792 602772
@l_os_cymru