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 38d7439 commit 36dc1fc
Show file tree
Hide file tree
Showing 8 changed files with 58 additions and 42 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="visits" basedir=".">
<xmlproperty file="build.properties.xml" semanticAttributes="true" keepRoot="false"/>
<project basedir="." default="xar" name="visits">
<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>
5 changes: 3 additions & 2 deletions collection.xconf
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@
<!-- start required facets and fields -->
<facet dimension="hsg-category" expression="'department'"/>
<facet dimension="hsg-publication" expression="'visits'"/>
<field name="hsg-fulltext" expression="visitor, description, from"/>
<field name="hsg-url" expression="'/departmenthistory/visits/' || year-from-date(./start-date)"/>
<field expression="visitor, description, from" name="hsg-fulltext"/>
<field expression="'/departmenthistory/visits/' || year-from-date(./start-date)"
name="hsg-url"/>
<!-- end required facets and fields -->
</text>
</lucene>
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/visits" abbrev="visits" version="0.4" spec="1.0">
<package abbrev="visits" name="http://history.state.gov/ns/data/visits" spec="1.0" version="0.4"
xmlns="http://expath.org/ns/pkg">
<title>Visits (data)</title>
</package>
3 changes: 2 additions & 1 deletion expath-pkg.xml.tmpl
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="@url@" abbrev="@name@" version="@version@" spec="1.0">
<package abbrev="@name@" name="@url@" spec="1.0" version="@version@"
xmlns="http://expath.org/ns/pkg">
<title>@title@</title>
</package>
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
4 changes: 2 additions & 2 deletions repo.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<meta xmlns="http://exist-db.org/xquery/repo" commit-id="87397e954313ef3de195009ef231ff46bad53f41" commit-time="1659361155">
<meta commit-id="7925851beedcc74ed102e1ff93eec6cc7cc8b6a6" commit-time="1683587877" xmlns="http://exist-db.org/xquery/repo">
<description>Visits (data)</description>
<author>Office of the Historian</author>
<website>https://history.state.gov</website>
Expand All @@ -10,5 +10,5 @@
<target>visits</target>
<prepare>pre-install.xql</prepare>
<finish/>
<permissions password="" user="hsg" group="hsg" mode="rw-rw-r--"/>
<permissions group="hsg" mode="rw-rw-r--" password="" user="hsg"/>
</meta>
4 changes: 2 additions & 2 deletions repo.xml.tmpl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<meta xmlns="http://exist-db.org/xquery/repo" commit-id="@commit-id@" commit-time="@commit-time@">
<meta commit-id="@commit-id@" commit-time="@commit-time@" xmlns="http://exist-db.org/xquery/repo">
<description>Visits (data)</description>
<author>Office of the Historian</author>
<website>https://history.state.gov</website>
Expand All @@ -10,5 +10,5 @@
<target>visits</target>
<prepare>pre-install.xql</prepare>
<finish/>
<permissions password="" user="hsg" group="hsg" mode="rw-rw-r--"/>
<permissions group="hsg" mode="rw-rw-r--" password="" user="hsg"/>
</meta>
33 changes: 21 additions & 12 deletions schema/visits.sch
Original file line number Diff line number Diff line change
@@ -1,36 +1,45 @@
<?xml version="1.0" encoding="UTF-8"?>
<schema xmlns="http://purl.oclc.org/dsdl/schematron" queryBinding="xslt3" xmlns:sqf="http://www.schematron-quickfix.com/validator/process">
<schema queryBinding="xslt3" xmlns="http://purl.oclc.org/dsdl/schematron"
xmlns:sqf="http://www.schematron-quickfix.com/validator/process">
<title>Visits Rules</title>

<p>This schematron file contains rules for visits.</p>

<let name="visit-ids" value="collection('../data?select=*.xml')//id"/>
<let name="next-id" value="max(($visit-ids ! (. cast as xs:integer))) + 1"/>

<pattern>
<rule context="visit">
<assert test="start-date le end-date">Start/end date problem: Start date should precede end date, but <value-of select="start-date"/> is given as the start date and <value-of select="end-date"/> is given as the end date</assert>
<assert test="start-date le end-date">Start/end date problem: Start date should precede
end date, but <value-of select="start-date"/> is given as the start date and
<value-of select="end-date"/> is given as the end date</assert>
</rule>
</pattern>

<pattern>
<rule context="visit[preceding-sibling::visit]">
<assert test="start-date ge preceding-sibling::visit[1]/start-date">Visit ordering problem: Visits should be given in chronological order, but visit <value-of select="id"/> starts before visit <value-of select="preceding-sibling::visit[1]/id"/></assert>
<assert test="start-date ge preceding-sibling::visit[1]/start-date">Visit ordering
problem: Visits should be given in chronological order, but visit <value-of
select="id"/> starts before visit <value-of
select="preceding-sibling::visit[1]/id"/></assert>
</rule>
</pattern>

<pattern>
<rule context="id">
<let name="this-id" value="./string()"/>
<let name="count-used" value="count($visit-ids[. = $this-id])"/>
<assert test="$count-used eq 1" sqf:fix="update-id">Visit ID problem: <value-of select="$count-used"/> other visit(s) also use the same ID, <value-of select="$this-id"/>.</assert>
<assert sqf:fix="update-id" test="$count-used eq 1">Visit ID problem: <value-of
select="$count-used"/> other visit(s) also use the same ID, <value-of
select="$this-id"/>.</assert>
<sqf:fix id="update-id">
<sqf:description>
<sqf:title>Fix ID (use next available ID, <value-of select="$next-id"/>)</sqf:title>
<sqf:title>Fix ID (use next available ID, <value-of select="$next-id"
/>)</sqf:title>
</sqf:description>
<sqf:replace match="text()" select="$next-id"/>
</sqf:fix>
</rule>
</pattern>
</schema>

</schema>

0 comments on commit 36dc1fc

Please sign in to comment.