Possible to preserve empty elements after running XSLT cleanup stylesheet?

523 views
Skip to first unread message

Andrea Briggs

unread,
Apr 24, 2015, 3:59:23 PM4/24/15
to isla...@googlegroups.com
Hi all,

I am an MLIS candidate working with the University of Pittsburgh's Digital Library staff to develop the MODS metadata entry form as part of an internship. We are currently running a VM instance of Islandora 7.x-1.4 with plans to migrate to a production environment, and have modified Priscilla Caplan's FSU Full MODS form to accomodate the copyrightMD namespace along with the MODS namespace, using copyrightMD to store information in the <mods:accessCondition> container as shown below:

<mods:accessCondition>
    <copyrightMD:copyright publication.status="unknown" copyright.status="unknown"/>
</mods:accessCondition>

However, <copyrightMD:copyright> as we use it is an empty element and only contains attributes (no text node). This meets the minimal requirement of copyrightMD. Islandora's XSLT cleanup stylesheet[1]  strips out any empty elements - including <copyrightMD:copyright> (and by extension, reading <mods:accessCondition> as an empty container, stripping that as well).

Is there a way to modify the cleanup stylesheet so that it hooks on the copyrightMD namespace (or some other way) to keep that empty element (and the surrounding <mods:accessCondition> container), while still stripping the other empty elements the form would generate as usual?

[1] https://github.com/UCLALibrary/islandora_drupal_base/blob/master/drupal/sites/all/modules/islandora/islandora_xml_forms/builder/self_transforms/islandora_cleanup_mods_extended.xsl

Bridger Dyson-Smith

unread,
Apr 24, 2015, 4:26:32 PM4/24/15
to isla...@googlegroups.com
Hi Andrea,

I think you can add an overriding template in the identity transform; e.g.

    <xsl:template match="mods:accessCondition">
        <xsl:copy>
            <xsl:apply-templates select="@*|node()"/>
        </xsl:copy>
    </xsl:template>

Not tested on a real example, but hopefully close enough to help.

Best,
Bridger

--
For more information about using this group, please read our Listserv Guidelines: http://islandora.ca/content/welcome-islandora-listserv
---
You received this message because you are subscribed to the Google Groups "islandora" group.
To unsubscribe from this group and stop receiving emails from it, send an email to islandora+...@googlegroups.com.
Visit this group at http://groups.google.com/group/islandora.
For more options, visit https://groups.google.com/d/optout.

Bolam, Michael R

unread,
Apr 27, 2015, 9:59:32 AM4/27/15
to isla...@googlegroups.com

Hi Bridger,

 

I’m working with Andrea on this project, and since she just wrapped up for the semester (and on a well-deserved break from working with the Form Builder), I wanted chime in and let you know that I was able to use your suggestion successfully. Thanks for the help!

 

In case anyone else is looking to do something similar, here’s the full style sheet, based on islandora_cleanup_mods_extended.xsl. I’ve run it over a few files and it seems to do what it’s supposed to do.

 

<xsl:stylesheet xmlns:copyrightMD="http://www.cdlib.org/inside/diglib/copyrightMD" version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:mods="http://www.loc.gov/mods/v3">
   
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes" media-type="text/xml"/>
   
<xsl:strip-space elements="*"/>
   
    
<xsl:template match="*[not(node())] | *[not(node()[2]) and node()/self::text() and not(normalize-space())]"/>   

    
<xsl:template match="node()|@*">
       
<xsl:copy>
           
<xsl:apply-templates select="node()[normalize-space()]|@*[normalize-space()]"/>
           
<xsl:apply-templates select="mods:accessCondition/copyrightMD:copyright"/>
       
</xsl:copy>
   
</xsl:template>
    
    
<xsl:template match="mods:accessCondition/copyrightMD:copyright">


       
<mods:accessCondition>
       
<xsl:copy>
           
<xsl:apply-templates select="@*|node()"/>
       
</xsl:copy>


       
</mods:accessCondition>
   
</xsl:template>
   
</xsl:stylesheet>

 

 

Mike

 

--

Michael Bolam

Metadata Librarian

Digital Scholarship Services

University Library System

University of Pittsburgh

Reply all
Reply to author
Forward
0 new messages