Skip to content

Instantly share code, notes, and snippets.

@claudemamo
Last active Dec 12, 2021
Embed
What would you like to do?
<nitf:NITF xmlns:nitf="urn:nitf:2.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<InvalidData>
4E49544630322E3130303342463031695F33303031612020203139393731323137313032363330436865636B7320616E20756E636F6D7072657373
656420313032347831303234203820626974206D6F6E6F20696D61676520776974682047454F63656E7472696320646174612E204169726669656C
6455202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020
2020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020
2020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020303030303030303030
3030EF...
</InvalidData>
</nitf:NITF>
<nitf:NITF xmlns:nitf="urn:nitf:2.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<nitf:ValidData>
<Header>
<FileProfileName>NITF</FileProfileName>
<FileVersion>02.10</FileVersion>
<ComplexityLevel>3</ComplexityLevel>
<StandardType>BF01</StandardType>
<OriginatingStationID>i_3001a</OriginatingStationID>
<FileDateAndTime>1997-12-17T10:26:30+00:00</FileDateAndTime>
<FileTitle>Checks an uncompressed 1024x1024 8 bit mono image with GEOcentric data. Airfield</FileTitle>
<SecurityClassification>U</SecurityClassification>
<SecurityClassificationSystem xsi:nil="true"/>
<Codewords xsi:nil="true"/>
<ControlAndHandling xsi:nil="true"/>
<ReleasingInstructions xsi:nil="true"/>
<DeclassificationType xsi:nil="true"/>
<DeclassificationDate xsi:nil="true"/>
<DeclassificationExemption xsi:nil="true"/>
<Downgrade xsi:nil="true"/>
<DowngradeDate xsi:nil="true"/>
<ClassificationText xsi:nil="true"/>
<ClassificationAuthorityType xsi:nil="true"/>
<ClassificationAuthority xsi:nil="true"/>
<ClassificationReason xsi:nil="true"/>
<SecuritySourceDate xsi:nil="true"/>
<SecurityControlNumber xsi:nil="true"/>
...
</nitf:ValidData>
</nitf:NITF>
<?xml version="1.0"?>
<smooks-resource-list xmlns="https://www.smooks.org/xsd/smooks-2.0.xsd"
xmlns:core="https://www.smooks.org/xsd/smooks/smooks-core-1.6.xsd"
xmlns:dfdl="https://www.smooks.org/xsd/smooks/dfdl-1.0.xsd">
<!-- ingest the stream from the input source (i.e., untrusted system) -->
<dfdl:parser schemaURI="/nitf.dfdl.xsd"/>
<core:smooks filterSourceOn="/NITF">
<core:action>
<core:inline>
<!-- consume the root event (i.e., 'NITF') and its descendants -->
<core:replace/>
</core:inline>
</core:action>
<core:config>
<smooks-resource-list>
<!-- happy path: serialize the valid event stream to NITF before writing it out to the execution result stream (i.e., trusted system) -->
<dfdl:unparser schemaURI="/nitf.dfdl.xsd" unparseOnNode="//*[not(self::InvalidData)]"
distinguishedRootNode="{urn:nitf:2.1}ValidData"/>
</smooks-resource-list>
</core:config>
</core:smooks>
<!-- unhappy path: write the invalid event stream to a side output resource -->
<core:smooks filterSourceOn="/NITF/InvalidData">
<core:action>
<core:outputTo outputStreamResource="deadLetterStream"/>
</core:action>
</core:smooks>
</smooks-resource-list>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment