-
Notifications
You must be signed in to change notification settings - Fork 41
Fix duplicate bf:relation from a 490 with a $v or $x #274
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
edsu
wants to merge
1
commit into
lcnetdev:master
Choose a base branch
from
edsu:duplicate-series-relation
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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,103 @@ | ||
| #!/usr/bin/env bash | ||
| # | ||
| # Convert every test record with both Saxon and libxslt and require the two | ||
| # results to agree. | ||
| # | ||
| # The XSpec suite runs under Saxon only, so a construct that Saxon evaluates | ||
| # correctly and libxslt does not passes CI and still produces wrong output for | ||
| # the many downstream users on libxslt -- lxml (Python), Nokogiri (Ruby), PHP's | ||
| # XSL extension, XML::LibXSLT (Perl) and xsltproc itself. | ||
| # | ||
| # Both results are rendered through test/normalize.xsl before comparison, by | ||
| # the same processor, so that indentation, attribute order and the placement of | ||
| # namespace declarations do not count as differences. | ||
| # | ||
| # Usage: | ||
| # SAXON_CP=/path/to/saxon-he-12.4.jar ./test/compare-processors.sh [file...] | ||
| # | ||
| # With no arguments it checks the records listed in DEFAULT_FILES below. Pass | ||
| # paths to check anything else -- pointing it at all of test/data is a quick | ||
| # way to see where else the two processors part company. | ||
|
|
||
| set -u | ||
|
|
||
| cd "$(dirname "$0")/.." | ||
|
|
||
| : "${SAXON_CP:?set SAXON_CP to the Saxon jar, e.g. /tmp/saxon/saxon-he-12.4.jar}" | ||
|
|
||
| command -v xsltproc >/dev/null || { echo "xsltproc not found"; exit 2; } | ||
|
|
||
| STYLESHEET=xsl/marc2bibframe2.xsl | ||
| NORMALIZE=test/normalize.xsl | ||
|
|
||
| # The transform stamps the current time into the work's admin metadata, which | ||
| # would differ between the two runs. | ||
| DATESTAMP=2020-01-01T00:00:00 | ||
|
|
||
| work=$(mktemp -d) | ||
| trap 'rm -rf "$work"' EXIT | ||
|
|
||
| # The records this check covers. Deliberately a subset for now: it starts with | ||
| # the series data, and should grow as other processor divergences are found and | ||
| # resolved. | ||
| DEFAULT_FILES=(test/data/ConvSpec-Process6-Series/*.xml) | ||
|
|
||
| if [ "$#" -gt 0 ]; then | ||
| files=("$@") | ||
| else | ||
| files=("${DEFAULT_FILES[@]}") | ||
| fi | ||
|
|
||
| failed=0 | ||
| checked=0 | ||
|
|
||
| for file in "${files[@]}"; do | ||
| checked=$((checked + 1)) | ||
|
|
||
| if ! xsltproc --stringparam pGenerationDatestamp "$DATESTAMP" \ | ||
| "$STYLESHEET" "$file" > "$work/libxslt.xml" 2> "$work/libxslt.err"; then | ||
| echo "FAIL $file" | ||
| echo " libxslt could not convert it:" | ||
| sed 's/^/ /' "$work/libxslt.err" | ||
| failed=$((failed + 1)) | ||
| continue | ||
| fi | ||
|
|
||
| if [ ! -s "$work/libxslt.xml" ]; then | ||
| echo "FAIL $file" | ||
| echo " libxslt produced no output" | ||
| sed 's/^/ /' "$work/libxslt.err" | ||
| failed=$((failed + 1)) | ||
| continue | ||
| fi | ||
|
|
||
| java -cp "$SAXON_CP" net.sf.saxon.Transform \ | ||
| -s:"$file" -xsl:"$STYLESHEET" "pGenerationDatestamp=$DATESTAMP" \ | ||
| -o:"$work/saxon.xml" 2> "$work/saxon.err" || { | ||
| echo "FAIL $file" | ||
| echo " Saxon could not convert it:" | ||
| sed 's/^/ /' "$work/saxon.err" | ||
| failed=$((failed + 1)) | ||
| continue | ||
| } | ||
|
|
||
| xsltproc "$NORMALIZE" "$work/libxslt.xml" > "$work/libxslt.txt" | ||
| xsltproc "$NORMALIZE" "$work/saxon.xml" > "$work/saxon.txt" | ||
|
|
||
| if ! diff -q "$work/libxslt.txt" "$work/saxon.txt" > /dev/null; then | ||
| echo "FAIL $file" | ||
| echo " libxslt and Saxon disagree (< libxslt, > Saxon), first 20 lines:" | ||
| diff "$work/libxslt.txt" "$work/saxon.txt" | head -20 | sed 's/^/ /' | ||
| failed=$((failed + 1)) | ||
| continue | ||
| fi | ||
|
|
||
| echo "ok $file" | ||
| done | ||
|
|
||
| echo | ||
| if [ "$failed" -gt 0 ]; then | ||
| echo "$failed of $checked records differ between processors" | ||
| exit 1 | ||
| fi | ||
| echo "$checked records convert identically under libxslt and Saxon" |
This file contains hidden or 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,22 @@ | ||
| <collection xmlns="http://www.loc.gov/MARC21/slim"> | ||
| <record> | ||
| <controlfield tag="001">1</controlfield> | ||
| <datafield tag="490" ind1="0" ind2=" "> | ||
| <subfield code="a">Lund studies in geography</subfield> | ||
| </datafield> | ||
| </record> | ||
| <record> | ||
| <controlfield tag="001">2</controlfield> | ||
| <datafield tag="490" ind1="0" ind2=" "> | ||
| <subfield code="a">Lund studies in geography ;</subfield> | ||
| <subfield code="v">no. 32</subfield> | ||
| </datafield> | ||
| </record> | ||
| <record> | ||
| <controlfield tag="001">3</controlfield> | ||
| <datafield tag="490" ind1="0" ind2=" "> | ||
| <subfield code="a">Lund studies in geography ;</subfield> | ||
| <subfield code="x">1234-5678</subfield> | ||
| </datafield> | ||
| </record> | ||
| </collection> |
This file contains hidden or 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,46 @@ | ||
| <?xml version="1.0" encoding="UTF-8"?> | ||
| <!-- | ||
| Render a conversion result as one line per node, so that output from two | ||
| XSLT processors can be compared without their serialization differences | ||
| (indentation, attribute order, where namespace declarations land) showing up | ||
| as false differences. Run it with the same processor over both files. | ||
| --> | ||
| <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> | ||
|
|
||
| <xsl:output method="text" encoding="UTF-8"/> | ||
| <xsl:strip-space elements="*"/> | ||
|
|
||
| <xsl:template match="/"> | ||
| <xsl:apply-templates select="*"/> | ||
| </xsl:template> | ||
|
|
||
| <xsl:template match="*"> | ||
| <xsl:param name="depth" select="0"/> | ||
| <xsl:call-template name="indent"> | ||
| <xsl:with-param name="n" select="$depth"/> | ||
| </xsl:call-template> | ||
| <xsl:value-of select="name()"/> | ||
| <xsl:for-each select="@*"> | ||
| <xsl:sort select="name()"/> | ||
| <xsl:value-of select="concat(' ', name(), '="', normalize-space(.), '"')"/> | ||
| </xsl:for-each> | ||
| <xsl:if test="normalize-space(text()) != ''"> | ||
| <xsl:value-of select="concat(' | ', normalize-space(text()))"/> | ||
| </xsl:if> | ||
| <xsl:text> </xsl:text> | ||
| <xsl:apply-templates select="*"> | ||
| <xsl:with-param name="depth" select="$depth + 1"/> | ||
| </xsl:apply-templates> | ||
| </xsl:template> | ||
|
|
||
| <xsl:template name="indent"> | ||
| <xsl:param name="n"/> | ||
| <xsl:if test="$n > 0"> | ||
| <xsl:text> </xsl:text> | ||
| <xsl:call-template name="indent"> | ||
| <xsl:with-param name="n" select="$n - 1"/> | ||
| </xsl:call-template> | ||
| </xsl:if> | ||
| </xsl:template> | ||
|
|
||
| </xsl:stylesheet> |
This file contains hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the one line fix! Everything else is just testing with xsltproc and docs.