Skip to content

Instantly share code, notes, and snippets.

@mnewt
Last active February 11, 2016 01:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mnewt/1c28e4f893aec8ce2c70 to your computer and use it in GitHub Desktop.
Save mnewt/1c28e4f893aec8ce2c70 to your computer and use it in GitHub Desktop.
clj-xpath namespace map issue
(ns testing
(:require [clj-xpath.core :as xp]))
(def ^:dynamic xml-doc
(slurp "xmlns-test.xml")
(xp/with-namespace-context (xp/xmlnsmap-from-root-node xml-doc)
(xp/$x "//lexsdigest:Person" xml-doc))
(xp/with-namespace-context (xp/xmlnsmap-from-root-node xml-doc)
(xp/$x "//lexsdigest:Person/nc:PersonName/nc:PersonGivenName" xml-doc))
(xp/with-namespace-context (xp/xmlnsmap-from-root-node xml-doc)
(xp/$x:text "./nc:PersonName/nc:PersonGivenName"
(first (xp/$x "//lexsdigest:Person" xml-doc))))
(xp/with-namespace-context (xp/xmlnsmap-from-root-node xml-doc)
(map
#(xp/$x:text "./nc:PersonName/nc:PersonGivenName" %)
(xp/$x "//lexsdigest:Person" xml-doc)))
<?xml version="1.0" encoding="UTF-8"?>
<ulexpd:doPublish
xmlns:ulex="http://ulex.gov/ulex/2.0"
xmlns:ulexpd="http://ulex.gov/publishdiscover/2.0"
xmlns:ulexcodes="http://ulex.gov/codes/2.0"
xmlns:ulexlib="http://ulex.gov/library/2.0"
xmlns:j="http://niem.gov/niem/domains/jxdm/4.1"
xmlns:nc="http://niem.gov/niem/niem-core/2.0"
xmlns:em="http://niem.gov/niem/domains/emergencyManagement/2.1"
xmlns:fs="http://niem.gov/niem/domains/familyServices/2.1"
xmlns:im="http://niem.gov/niem/domains/immigration/2.1"
xmlns:scr="http://niem.gov/niem/domains/screening/2.1"
xmlns:s="http://niem.gov/niem/structures/2.0"
xmlns:lexs="http://lexs.gov/lexs/4.0"
xmlns:wsa="http://www.w3.org/2005/08/addressing"
xmlns:lexsdigest="http://lexs.gov/digest/4.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://ulex.gov/publishdiscover/2.0 ../../xsd/ulex.gov/ulex-publish-discover/2.0/ulex-publish-discover.xsd">
<!--======================= Person with Enforcement Official Role =======================-->
<lexsdigest:EntityPerson>
<lexsdigest:Metadata s:id="MOff1">
<nc:SourceIDText>Per12345</nc:SourceIDText>
</lexsdigest:Metadata>
<lexsdigest:Person s:id="Off1" s:metadata="MOff1">
<nc:PersonName>
<nc:PersonGivenName>Bob</nc:PersonGivenName>
<nc:PersonSurName>Evans</nc:PersonSurName>
</nc:PersonName>
</lexsdigest:Person>
<j:EnforcementOfficial>
<nc:RoleOfPersonReference s:ref="Off1"/>
<j:EnforcementOfficialBadgeIdentification>
<nc:IdentificationID>AGENCY3700</nc:IdentificationID>
</j:EnforcementOfficialBadgeIdentification>
</j:EnforcementOfficial>
</lexsdigest:EntityPerson>
<!--======================= Person with Arrestee Role =======================-->
<lexsdigest:EntityPerson s:id="EArr1">
<lexsdigest:Metadata s:id="MArr1">
<nc:SourceIDText>Per12346</nc:SourceIDText>
</lexsdigest:Metadata>
<lexsdigest:Person s:id="Arr1" s:metadata="MArr1">
<nc:PersonAgeMeasure>
<nc:MeasurePointValue>28</nc:MeasurePointValue>
<nc:TimeUnitCode>ANN</nc:TimeUnitCode>
</nc:PersonAgeMeasure>
<nc:PersonAlternateName>
<nc:PersonFullName>Tiny</nc:PersonFullName>
</nc:PersonAlternateName>
<nc:PersonBirthDate>
<nc:YearMonth>1978-01</nc:YearMonth>
</nc:PersonBirthDate>
<nc:PersonCitizenshipFIPS10-4Code>US</nc:PersonCitizenshipFIPS10-4Code>
<nc:PersonEyeColorCode>BLU</nc:PersonEyeColorCode>
<nc:PersonHairColorCode>BRO</nc:PersonHairColorCode>
<nc:PersonHeightMeasure>
<nc:MeasurePointValue>72</nc:MeasurePointValue>
<nc:LengthUnitCode>INH</nc:LengthUnitCode>
</nc:PersonHeightMeasure>
<nc:PersonName>
<nc:PersonGivenName>Bubba</nc:PersonGivenName>
<nc:PersonMiddleName>Ray</nc:PersonMiddleName>
<nc:PersonSurName>Johnson</nc:PersonSurName>
</nc:PersonName>
<nc:PersonRaceText>White</nc:PersonRaceText>
<nc:PersonSexCode>M</nc:PersonSexCode>
<nc:PersonSSNIdentification>
<nc:IdentificationID>444455555</nc:IdentificationID>
</nc:PersonSSNIdentification>
<nc:PersonWeightMeasure>
<nc:MeasurePointValue>180</nc:MeasurePointValue>
<nc:WeightUnitCode>LBR</nc:WeightUnitCode>
</nc:PersonWeightMeasure>
<j:PersonAugmentation>
<nc:DriverLicense>
<nc:DriverLicenseIdentification>
<nc:IdentificationID>E775522</nc:IdentificationID>
<nc:IdentificationEffectiveDate>
<nc:Date>1998-04-16</nc:Date>
</nc:IdentificationEffectiveDate>
<nc:IdentificationExpirationDate>
<nc:Date>2004-04-01</nc:Date>
</nc:IdentificationExpirationDate>
<j:IdentificationJurisdictionNCICLISCode>WV</j:IdentificationJurisdictionNCICLISCode>
</nc:DriverLicenseIdentification>
</nc:DriverLicense>
<j:PersonFBIIdentification>
<nc:IdentificationID>12345</nc:IdentificationID>
</j:PersonFBIIdentification>
<j:PersonStateFingerprintIdentification>
<nc:IdentificationID>WV5692345</nc:IdentificationID>
</j:PersonStateFingerprintIdentification>
</j:PersonAugmentation>
</lexsdigest:Person>
<j:ArrestSubject>
<nc:RoleOfPersonReference s:ref="Arr1"/>
</j:ArrestSubject>
</lexsdigest:EntityPerson>
</ulexpd:doPublish>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment