-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
a few more workarounds for the xsd namespace prefix
- Loading branch information
Mark Custer
committed
Feb 26, 2021
1 parent
b92156c
commit f63e428
Showing
5 changed files
with
246 additions
and
208 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" | ||
xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:eac="https://archivists.org/ns/eac/v2" | ||
xmlns:ead3="http://ead3.archivists.org/schema/" xmlns:ead="http://archivists.org/ns/ead/v4" | ||
exclude-result-prefixes="#all" version="3.0"> | ||
|
||
<xsl:output method="xml" encoding="UTF-8" indent="true"/> | ||
<xsl:mode on-no-match="shallow-copy"/> | ||
|
||
<xsl:param name="schema" select="'eac'"/> | ||
<!-- for EAD, will need to pass the param of 'schema', until we change the namespace not to end in 'schema'. this is due to how Trang selects the ns prefix --> | ||
|
||
<!-- for eac, this gets us 'https://archivists.org/ns/eac/v2' --> | ||
<xsl:variable name="schema-ns-uri" select="document('')/*/namespace::*[local-name() eq $schema]"/> | ||
|
||
<!-- and to get the "v2" prefix from the namespace URI, we do this --> | ||
<xsl:param name="trang-ns-prefix" select="tokenize($schema-ns-uri, '/')[last()]"/> | ||
|
||
<xsl:template match="xs:*"> | ||
<xsl:element name="{name()}" namespace="{namespace-uri()}"> | ||
<xsl:for-each select="namespace::*"> | ||
<xsl:namespace name="{if (local-name() = $trang-ns-prefix) then $schema else local-name()}" select="string(.)"/> | ||
</xsl:for-each> | ||
<xsl:apply-templates select="@*|node()"/> | ||
</xsl:element> | ||
</xsl:template> | ||
|
||
<xsl:template match="@type[starts-with(., $trang-ns-prefix)] | @base[starts-with(., $trang-ns-prefix)]"> | ||
<xsl:attribute name="{local-name()}"> | ||
<xsl:value-of select="$schema || ':' || substring-after(., ':')"/> | ||
</xsl:attribute> | ||
</xsl:template> | ||
|
||
</xsl:stylesheet> |
Oops, something went wrong.