Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Update to ukf-members 1.4.0
Handles members.xml schema 1.7, which introduces a mandatory orgID attribute for all Grant and GrantAll elements. Move to presenting the schema from ukf-data/members to the Members constructor; this allows minor additional schema evolutions to be made without needing ukf-members to be rebuilt. utilities/2016-10-06 holds scripts used for the members.xml conversion.
Showing
6 changed files
with
91 additions
and
1 deletion.
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
Binary file not shown.
Binary file not shown.
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,25 @@ | ||
# `utilities/2016-10-06` | ||
|
||
These transforms and scripts were used to add an `orgID` attribute to the | ||
`Grant` and `GrantAll` elements on all participants in the `members.xml` file. | ||
|
||
## Step 1 | ||
|
||
Generate `id-to-name.txt` as follows: | ||
|
||
xsltproc --output id-to-name.txt gen-id-to-name.xsl members/members.xml | ||
|
||
This file contains a mapping between organization IDs and canonical | ||
organization names, like this: | ||
|
||
ukforg4590 Ian A. Young | ||
|
||
The first field is separated from the second by a single tab character. | ||
|
||
## Step 2 | ||
|
||
Apply the `patch.pl` script to generate a new version of `members.xml`. | ||
|
||
./patch.pl members/members.xml >members/members-new.xml | ||
|
||
Compare the two versions of the file before replacing the old one. |
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,19 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<xsl:stylesheet version="1.0" | ||
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" | ||
xmlns:members="http://ukfederation.org.uk/2007/01/members" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> | ||
|
||
<xsl:output method="text" encoding="UTF-8"/> | ||
|
||
<xsl:template match="members:Member"> | ||
<xsl:value-of select="@ID"/> | ||
<xsl:text>	</xsl:text> | ||
<xsl:value-of select="members:Name"/> | ||
<xsl:text> </xsl:text> | ||
</xsl:template> | ||
|
||
<xsl:template match="text()"> | ||
<!-- do nothing --> | ||
</xsl:template> | ||
</xsl:stylesheet> |
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,32 @@ | ||
#!/usr/bin/env perl -W | ||
|
||
open(F, "id-to-name.txt") || die "could not open id-to-name map"; | ||
while (<F>) { | ||
my ($orgid, $name) = split /[\t\n]/; | ||
#print "name='$name' --> orgid='$orgid'\n"; | ||
$name_to_orgid{$name} = $orgid; | ||
} | ||
close(F); | ||
|
||
while (<>) { | ||
# 12 2 3 3 1 4 4 5 5 | ||
if (/^((.*)<Grant(All)?)\s+to=\"([^\"]+)\"(.*)$/) { | ||
my $pre = $1; | ||
my $xmlName = $4; | ||
my $post = $5; | ||
my $name = $xmlName; | ||
$name =~ s/\&\;/\&/; | ||
#print "pre -$pre- xmlName -$xmlName- name -$name- post -$post-\n"; | ||
my $orgID = $name_to_orgid{$name}; | ||
if (!defined($orgID)) { | ||
die "no map for -$xmlName- -$name-\n"; | ||
} | ||
print "$pre to=\"$xmlName\" orgID=\"$orgID\"$post\n"; | ||
#print "$pre orgID=\"$orgID\" to=\"$xmlName\"$post\n"; | ||
} elsif (/<Grant(All)?\s+/) { | ||
die "bad Grant $_"; | ||
} else { | ||
print $_; | ||
} | ||
} | ||
close(F); |