Skip to content

Commit

Permalink
Format & indent
Browse files Browse the repository at this point in the history
  • Loading branch information
joewiz committed Mar 16, 2024
1 parent bff23c9 commit b395ab3
Show file tree
Hide file tree
Showing 16 changed files with 381 additions and 185 deletions.
41 changes: 22 additions & 19 deletions build.xml
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<project default="xar" name="pocom" basedir=".">
<xmlproperty file="build.properties.xml" semanticAttributes="true" keepRoot="false"/>
<project basedir="." default="xar" name="pocom">
<xmlproperty file="build.properties.xml" keepRoot="false" semanticAttributes="true"/>
<property name="build.dir" value="build"/>
<property name="git.repo.path" value="${basedir}/.git"/>
<available file="${git.repo.path}" type="dir" property="git.present"/>
<available file="${git.repo.path}" property="git.present" type="dir"/>

<target name="clean">
<echo message="Deleting xar files..."/>
<delete dir="${build.dir}" failonerror="false"/>
<delete file="${basedir}/expath-pkg.xml" failonerror="false"/>
<delete file="${basedir}/repo.xml" failonerror="false"/>
<delete failonerror="false" file="${basedir}/expath-pkg.xml"/>
<delete failonerror="false" file="${basedir}/repo.xml"/>
</target>
<target name="xar" depends="clean,git.revision" description="create xar file">

<target depends="clean,git.revision" description="create xar file" name="xar">
<echo message="Creating build folder..."/>
<mkdir dir="${build.dir}"/>

<echo message="Apply values to expath-pkg.xml..."/>
<copy todir="${basedir}" overwrite="true" verbose="true">
<copy overwrite="true" todir="${basedir}" verbose="true">
<fileset file="*.xml.tmpl"/>
<filterchain>
<replacetokens>
Expand All @@ -39,34 +39,37 @@
<echo message="------------------------------------------------------------"/>
<echo message="Creating xar file..."/>
<echo message="------------------------------------------------------------"/>

<zip basedir="${basedir}" destfile="${build.dir}/${app.name}-${app.version}.xar">
<exclude name="${build.dir}/**"/>
<exclude name="*.tmpl"/>
</zip>
</zip>
</target>

<target name="git.revision" description="Store git revision in ${repository.version}" if="git.present">
<exec executable="git" outputproperty="git.revision" failifexecutionfails="false" errorproperty="">
<target description="Store git revision in ${repository.version}" if="git.present"
name="git.revision">
<exec errorproperty="" executable="git" failifexecutionfails="false"
outputproperty="git.revision">
<arg value="--git-dir=${git.repo.path}"/>
<arg value="rev-parse"/>
<arg value="rev-parse"/>
<arg value="HEAD"/>
</exec>
<condition property="repository.version" value="${git.revision}" else="unknown">
<condition else="unknown" property="repository.version" value="${git.revision}">
<and>
<isset property="git.revision"/>
<length string="${git.revision}" trim="yes" length="0" when="greater"/>
<length length="0" string="${git.revision}" trim="yes" when="greater"/>
</and>
</condition>
<echo>Git repo: ${repository.version}</echo>

<exec executable="git" outputproperty="git.time" failifexecutionfails="false" errorproperty="">

<exec errorproperty="" executable="git" failifexecutionfails="false"
outputproperty="git.time">
<arg value="--git-dir=${git.repo.path}"/>
<arg value="show"/>
<arg value="-s"/>
<arg value="--format=%ct"/>
<arg value="${git.revision}"/>
</exec>
<echo>Git time: ${git.time}</echo>
</target>
</project>
</target>
</project>
109 changes: 67 additions & 42 deletions code-tables/all-codes-html.xq
Original file line number Diff line number Diff line change
Expand Up @@ -4,68 +4,93 @@ import module namespace style = "http://style.syntactica.com/us-state-hist" at "

(: return the longest string in a sequence of strings :)
declare function local:max-length($string-seq as xs:string*) as xs:string {
let $max := max (for $s in $string-seq return string-length($s))
return $string-seq[string-length(.) = $max][1]
let $max := max(for $s in $string-seq
return
string-length($s))
return
$string-seq[string-length(.) = $max][1]
};

(: the number of blueprint columns to span for this sequnce of strings :)
declare function local:bp-column-width($string-seq as xs:string*) as xs:integer {
let $chars-per-column := xs:double(6)
let $max := max (for $s in $string-seq return string-length($s))
return floor( ($max div $chars-per-column) + 1)
let $max := max(for $s in $string-seq
return
string-length($s))
return
floor(($max div $chars-per-column) + 1)
};

let $all-codes-path := concat($style:db-path-to-app, '/code-tables/all-codes.xq')

(: not working - perhaps because of rewrite rules? let $code-table := util:eval(xs:anyURI($all-codes-path)) :)
let $all-codes := doc('http://localhost/cms/apps/principals-chiefs/edit/all-codes')/code-tables
let $all-codes := doc('http://localhost/cms/apps/principals-chiefs/edit/all-codes')/code-tables
let $table-names := $all-codes//code-table/name/text()

let $style2 :=
<style type="text/css"><![CDATA[
<style
type="text/css"><![CDATA[
.code-table {padding: 10px;}
.metric-label {font-weight: bold;}
]]></style>

let $content :=
<div class="content">
{$style2}
Path := {$all-codes-path}<br/>
Table Count= {count($table-names)}<br/>
Item Count= {count($all-codes//item)}<br/>
{for $table-name in $table-names
let $table := $all-codes/code-table[name=$table-name]
let $max-label-length := local:max-length($table/items/item/label/text())
let $max-value-length := local:max-length($table/items/item/value/text())
let $label-bp-columns := local:bp-column-width($table/items/item/label/text())
let $value-bp-columns := local:bp-column-width($table/items/item/value/text())
return
<div class="code-table">
<div class="metric"><span class="metric-label">Table Name: </span>{$table-name}</div>
<div class="metric">Description: {$table/description/text()} </div>
<div class="metric">Items in Table: {count($table/items/item)} </div>
<div class="metric">Longest Label: {$max-label-length} </div>
<div class="metric">Longest Value: {$max-value-length} </div>
<!--
<div
class="content">
{$style2}
Path := {$all-codes-path}<br/>
Table Count= {count($table-names)}<br/>
Item Count= {count($all-codes//item)}<br/>
{
for $table-name in $table-names
let $table := $all-codes/code-table[name = $table-name]
let $max-label-length := local:max-length($table/items/item/label/text())
let $max-value-length := local:max-length($table/items/item/value/text())
let $label-bp-columns := local:bp-column-width($table/items/item/label/text())
let $value-bp-columns := local:bp-column-width($table/items/item/value/text())
return
<div
class="code-table">
<div
class="metric"><span
class="metric-label">Table Name: </span>{$table-name}</div>
<div
class="metric">Description: {$table/description/text()}
</div>
<div
class="metric">Items in Table: {count($table/items/item)}
</div>
<div
class="metric">Longest Label: {$max-label-length}
</div>
<div
class="metric">Longest Value: {$max-value-length}
</div>
<!--
<div class="metric">BP Columns for Label: {$label-bp-columns} </div>
<div class="metric">BP Columns for Value: {$value-bp-columns} </div>
-->

<table class="span-{$label-bp-columns + $value-bp-columns + 1}">
<thead>
<th class="span-{ local:bp-column-width($table/items/item/label/text()) }">Item</th>
<th class="span-{ local:bp-column-width($table/items/item/value/text()) } last">Value</th>
</thead>
<tbody>{ for $item in $all-codes/code-table[name=$table-name]/items/item
return
<tr>
<td>{$item/label/text()}</td>
<td>{$item/value/text()}</td>
</tr>
}</tbody>
</table>
<hr/>
</div>

<table
class="span-{$label-bp-columns + $value-bp-columns + 1}">
<thead>
<th
class="span-{local:bp-column-width($table/items/item/label/text())}">Item</th>
<th
class="span-{local:bp-column-width($table/items/item/value/text())} last">Value</th>
</thead>
<tbody>{
for $item in $all-codes/code-table[name = $table-name]/items/item
return
<tr>
<td>{$item/label/text()}</td>
<td>{$item/value/text()}</td>
</tr>
}</tbody>
</table>
<hr/>
</div>
}
</div>
return style:assemble-page($content)
return
style:assemble-page($content)
6 changes: 3 additions & 3 deletions collection.xconf
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@
<!-- Lucene index configuration -->
<lucene>
<analyzer class="org.apache.lucene.analysis.standard.StandardAnalyzer"/>
<text qname="persName" index="no">
<text index="no" qname="persName">
<!-- start required facets and fields -->
<facet dimension="hsg-category" expression="'department'"/>
<facet dimension="hsg-publication" expression="'pocom'"/>
<field name="hsg-fulltext"/>
<field name="hsg-url" expression="'/departmenthistory/people/' || parent::person/id"/>
<field expression="'/departmenthistory/people/' || parent::person/id" name="hsg-url"/>
<!-- end required facets and fields -->
</text>
</lucene>

<!-- Range index configuration -->
<range>
<create qname="category" type="xs:string"/>
Expand Down
3 changes: 2 additions & 1 deletion expath-pkg.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<package xmlns="http://expath.org/ns/pkg" name="http://history.state.gov/ns/data/pocom" abbrev="pocom" version="0.5" spec="1.0">
<package abbrev="pocom" name="http://history.state.gov/ns/data/pocom" spec="1.0" version="0.5"
xmlns="http://expath.org/ns/pkg">
<title>Principal Officers &amp; Chiefs of Mission (data)</title>
</package>
2 changes: 1 addition & 1 deletion missions-countries/papua-new-guinea.xml
Original file line number Diff line number Diff line change
Expand Up @@ -408,5 +408,5 @@
<last-modified-date>2019-12-12</last-modified-date>
</chief>
</chiefs>
<other-nominees/>
<other-nominees/>
</country-mission>
2 changes: 1 addition & 1 deletion missions-countries/solomon-islands.xml
Original file line number Diff line number Diff line change
Expand Up @@ -410,5 +410,5 @@
<last-modified-date>2020-01-28</last-modified-date>
</chief>
</chiefs>
<other-nominees/>
<other-nominees/>
</country-mission>
2 changes: 1 addition & 1 deletion missions-countries/vanuatu.xml
Original file line number Diff line number Diff line change
Expand Up @@ -300,5 +300,5 @@
<last-modified-date>2019-12-12</last-modified-date>
</chief>
</chiefs>
<other-nominees/>
<other-nominees/>
</country-mission>
Original file line number Diff line number Diff line change
Expand Up @@ -655,5 +655,5 @@
<last-modified-date>2020-10-06</last-modified-date>
</principal>
</principals>
<other-appointees/>
<other-appointees/>
</principal-position>
Original file line number Diff line number Diff line change
Expand Up @@ -734,5 +734,5 @@
<last-modified-date>2019-08-08</last-modified-date>
</principal>
</principals>
<other-appointees/>
<other-appointees/>
</principal-position>
7 changes: 4 additions & 3 deletions pre-install.xql
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
xquery version "1.0";

import module namespace xdb="http://exist-db.org/xquery/xmldb";
import module namespace xdb = "http://exist-db.org/xquery/xmldb";

(: The following external variables are set by the repo:deploy function :)

Expand All @@ -14,10 +14,11 @@ declare variable $target external;
declare function local:mkcol-recursive($collection, $components) {
if (exists($components)) then
let $newColl := concat($collection, "/", $components[1])
return (
return
(
xdb:create-collection($collection, $components[1]),
local:mkcol-recursive($newColl, subsequence($components, 2))
)
)
else
()
};
Expand Down
7 changes: 4 additions & 3 deletions repo.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<meta xmlns="http://exist-db.org/xquery/repo" commit-id="61bec335e6e51c4804b3fc960164445fb33f7772" commit-time="1659362592">
<meta commit-id="61bec335e6e51c4804b3fc960164445fb33f7772" commit-time="1659362592"
xmlns="http://exist-db.org/xquery/repo">
<description>Principal Officers &amp; Chiefs of Mission (data)</description>
<author>Office of the Historian</author>
<website>https://history.state.gov</website>
Expand All @@ -10,5 +11,5 @@
<target>pocom</target>
<prepare>pre-install.xql</prepare>
<finish/>
<permissions password="" user="hsg" group="hsg" mode="rw-rw-r--"/>
</meta>
<permissions group="hsg" mode="rw-rw-r--" password="" user="hsg"/>
</meta>
41 changes: 26 additions & 15 deletions schema/concurrent-appointments.sch
Original file line number Diff line number Diff line change
@@ -1,39 +1,50 @@
<?xml version="1.0" encoding="UTF-8"?>
<schema xmlns="http://purl.oclc.org/dsdl/schematron" queryBinding="xslt2"
<schema queryBinding="xslt2" xmlns="http://purl.oclc.org/dsdl/schematron"
xmlns:sqf="http://www.schematron-quickfix.com/validator/process">
<!-- See documentation on Saxon-specific collection syntax used below: http://www.saxonica.com/documentation/index.html#!sourcedocs/collections -->
<let name="chief-ids" value="(collection('../missions-orgs?select=*.xml')//chief/id, collection('../missions-countries?select=*.xml')//chief/id)"/>
<!-- See documentation on Saxon-specific collection syntax used below: http://www.saxonica.com/documentation/index.html#!sourcedocs/collections -->
<let name="chief-ids"
value="(collection('../missions-orgs?select=*.xml')//chief/id, collection('../missions-countries?select=*.xml')//chief/id)"/>
<pattern>
<rule context="id">
<let name="basename" value="replace(base-uri(.), '^.*/(.*?)$', '$1')"/>
<assert test="$basename = concat(., '.xml')">The id “<value-of select="."/>” does
not match filename “<value-of select="$basename"/>”</assert>
<assert test="matches(., '^[\da-z-]+$')">The id
“<value-of select="."/>” must contain only lower case letters, numbers, and hyphens</assert>
<assert test="$basename = concat(., '.xml')">The id “<value-of select="."/>” does not
match filename “<value-of select="$basename"/>”</assert>
<assert test="matches(., '^[\da-z-]+$')">The id “<value-of select="."/>” must contain
only lower case letters, numbers, and hyphens</assert>
</rule>
</pattern>
<pattern>
<rule context="person-id">
<assert test="matches(., '^[a-z-]+\d?$')">The person-id “<value-of select="."/>” should only contain lower-case letters and hyphens, with an optional digit as the last character</assert>
<assert test="doc-available(concat('../people/', substring(., 1, 1), '/', ., '.xml'))">The person-id “<value-of select="."/>” was not found in the people collection.</assert>
<assert test="matches(., '^[a-z-]+\d?$')">The person-id “<value-of select="."/>” should
only contain lower-case letters and hyphens, with an optional digit as the last
character</assert>
<assert test="doc-available(concat('../people/', substring(., 1, 1), '/', ., '.xml'))"
>The person-id “<value-of select="."/>” was not found in the people
collection.</assert>
<!--<assert test="doc(concat('http://localhost:8080/services/check-person-id?person-id=', .))/result/is-valid = 'true'">The person-id “<value-of select="."/>” was not found in the database.</assert>-->
</rule>
</pattern>
<pattern>
<rule context="locale-id">
<!-- NOTE: THIS PATH TO GSH ASSUMES THAT GSH APP IS IN THE HSG-PROJECT REPOS DIRECTORY -->
<assert test=". = root(.)/country-mission/territory-id or doc-available(concat('../../gsh/data/locales/', ., '.xml'))">The locale-id “<value-of select="."/>” was not found in the gsh locales collection.</assert>
<assert
test=". = root(.)/country-mission/territory-id or doc-available(concat('../../gsh/data/locales/', ., '.xml'))"
>The locale-id “<value-of select="."/>” was not found in the gsh locales
collection.</assert>
</rule>
</pattern>
<pattern>
<rule context="contemporary-territory-id">
<!-- NOTE: THIS PATH TO GSH ASSUMES THAT GSH APP IS IN THE HSG-PROJECT REPOS DIRECTORY -->
<assert test="doc-available(concat('../../gsh/data/territories/', ., '.xml'))">The contemporary-territory-id “<value-of select="."/>” was not found in the gsh territory collection.</assert>
<assert test="doc-available(concat('../../gsh/data/territories/', ., '.xml'))">The
contemporary-territory-id “<value-of select="."/>” was not found in the gsh
territory collection.</assert>
</rule>
</pattern>
<pattern>
<rule context="chief-id">
<assert test=". = $chief-ids">The chief-id “<value-of select="."/>” was not found in the missions-countries or missions-orgs collection as a chief/id.</assert>
<assert test=". = $chief-ids">The chief-id “<value-of select="."/>” was not found in the
missions-countries or missions-orgs collection as a chief/id.</assert>
</rule>
</pattern>
<pattern>
Expand All @@ -43,8 +54,8 @@
</pattern>
<pattern>
<rule context="last-modified-date">
<assert test="xs:date(.) ge xs:date(./preceding-sibling::created-date)">Last
updated date should come after the created date</assert>
<assert test="xs:date(.) ge xs:date(./preceding-sibling::created-date)">Last updated
date should come after the created date</assert>
</rule>
</pattern>
</schema>
</schema>
Loading

0 comments on commit b395ab3

Please sign in to comment.