1. btingle
  2. at2oac

Commits

btingle  committed 75f72fa

now removes xmlns="urn:isbn:1-931666-22-9" by default (can retain)
more comments esp. for parameter options

  • Participants
  • Parent commits 80374f3
  • Branches default

Comments (0)

Files changed (2)

File README

View file
 - turns did/container/@label to did/physdesc or removes the lables
   depending on the value of stylesheet parameter label-to-physdesc
 
+- defaults to stripping out xsi:schemaLocation and putting the ead into
+  xmlns=""; to preserve xsi:schemaLocation and xmlns="urn:isbn:1-931666-22-9"
+  use stylesheet parameter strip-namespace of something other than 'yes'
+
 Produced by the California Digital Library, Digital Special Collections
 	http://www.cdlib.org/services/dsc/
+
+Issue tracker:
+	http://bitbucket.org/btingle/at2oac/issues

File at2oac.xsl

View file
 <xsl:stylesheet 
   version="1.0" 
   xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xmlns:ead="urn:isbn:1-931666-22-9"
   xmlns="urn:isbn:1-931666-22-9">
 
+<!-- set strip-namespace to anything other than yes to
+     disable default stripping
+-->
+<xsl:param name="strip-namespace" select="'yes'"/>
+
+<!-- set label-to-physdesc to anything other than '' to 
+     disable default removal of mis-labeled container/@label's
+     and they will be converted to sibling <physdesc>'s instead
+-->
+<xsl:param name="label-to-physdesc"/> 
+
+<!-- supply alternate dsc type or use default -->
 <xsl:param name="dsc-type" select="'combined'"/>
-<xsl:param name="repositorycode" select="/ead:ead/ead:eadheader/ead:eadid/@mainagencycode"/>
+
+<!-- supply repositorycode or use default -->
+<xsl:param 
+	name="repositorycode" 
+	select="/ead:ead/ead:eadheader/ead:eadid/@mainagencycode"/>
+
+<!-- supply countrycode or use default -->
 <xsl:param 
 	name="countrycode" 
 	select="translate(
 		/ead:ead/ead:eadheader/ead:eadid/@countrycode,
 		'abcdefghijklmnopqrstuvwxyz', 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' )" />
 
-<xsl:param name="namespace" select="'urn:isbn:1-931666-22-9'"/>
-
-<xsl:param name="label-to-physdesc"/> 
+<xsl:variable name="namespace">
+  <xsl:choose>
+    <xsl:when test="$strip-namespace = 'yes'"/>
+    <xsl:otherwise>
+      <xsl:text>urn:isbn:1-931666-22-9</xsl:text>
+    </xsl:otherwise>
+  </xsl:choose>
+</xsl:variable>
 
 <!-- root template -->
 <xsl:template match="/|comment()|processing-instruction()">
   </xsl:if>
 </xsl:template>
 
-<!-- identity -->
-<xsl:template match="@*|node()">
-  <xsl:copy>
-    <xsl:apply-templates select="@*|node()"/>
-  </xsl:copy>
+<!-- modified identity templates -->
+
+<xsl:template match="*">
+  <xsl:choose>
+    <xsl:when test="$namespace!=''">
+      <xsl:copy>
+        <xsl:apply-templates select="@*|node()"/>
+      </xsl:copy>
+    </xsl:when>
+    <xsl:otherwise>
+      <xsl:element name="{local-name()}" namespace="{$namespace}">
+        <xsl:apply-templates select="@*|node()"/>
+      </xsl:element>
+    </xsl:otherwise>
+  </xsl:choose>
+</xsl:template>
+
+<xsl:template match="@*">
+  <xsl:choose>
+    <xsl:when test="$namespace!=''">
+      <xsl:copy>
+        <xsl:apply-templates select="@*|node()"/>
+      </xsl:copy>
+    </xsl:when>
+    <xsl:otherwise>
+      <xsl:attribute name="{local-name()}">
+        <xsl:value-of select="."/>
+      </xsl:attribute>
+    </xsl:otherwise>
+  </xsl:choose>
+</xsl:template>
+
+<xsl:template match="@xsi:*">
+  <xsl:choose>
+    <xsl:when test="$namespace!=''">
+      <xsl:copy>
+        <xsl:apply-templates select="@*|node()"/>
+      </xsl:copy>
+    </xsl:when>
+    <xsl:otherwise/>
+  </xsl:choose>
 </xsl:template>
 
 </xsl:stylesheet>