| 1 | #!/usr/bin/envscip-shell filesystem . . `/usr/bin/env`. bash |
| 2 | |
| 3 | function assert_correct_xlinksscip-shell shell shell-project 0.0.0 assert_correct_xlinks().() |
| 4 | { |
| 5 | local DS=$1 |
| 6 | local stderr=$(mktempscip-shell system . . mktemp.) |
| 7 | $OSCAP info $DS 2> $stderr |
| 8 | diffscip-shell system . . diff. $stderr /dev/nullscip-shell filesystem . . `/dev/null`. |
| 9 | rmscip-shell system . . rm. $stderr |
| 10 | |
| 11 | # First of all make sure that there is at least one ds:component-ref. |
| 12 | [scip-shell system . . `[`. "$($XPATH $DS 'count(//*[local-name()="component-ref"])')" != "0" ] |
| 13 | # We want to catch cases when this element has different namespace. |
| 14 | local ns=$($XPATH $DS 'name(//*[local-name()="component-ref"][1])' | sedscip-shell system . . sed. 's/:.*$/:/') |
| 15 | [scip-shell system . . `[`. "$ns" != "component-ref" ] || ns="" |
| 16 | # Ensure there is at least some xlink. |
| 17 | [scip-shell system . . `[`. "`$XPATH $DS \"count(//${ns}component-ref/@xlink:href)\"`" != "0" ] |
| 18 | # This asserts that there is none component-ref/xlink:href broken. |
| 19 | # Previously, we have seen datastreams with broken xlinks (see trac#286). |
| 20 | [scip-shell system . . `[`. "`$XPATH $DS \"count(//${ns}component-ref[substring(@xlink:href, 2, 10000) != (//${ns}component/@${ns}id | //${ns}extended-component/@${ns}id)])\"`" == "0" ] |
| 21 | } |