Skip to content

Commit

Permalink
trying to resolve the 'title' tag
Browse files Browse the repository at this point in the history
Signed-off-by: Emily Rodriguez <ecrodriguez@mitre.org>
  • Loading branch information
em-c-rod committed Sep 18, 2023
1 parent 351ab87 commit 65e199b
Showing 1 changed file with 19 additions and 5 deletions.
24 changes: 19 additions & 5 deletions src/utilities/xccdf.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,18 @@
import { XMLParser } from 'fast-xml-parser'
import {XMLParser} from 'fast-xml-parser'
import {toXML} from 'jstoxml';
import * as htmlparser from 'htmlparser2'
import _ from 'lodash'
import {DecodedDescription} from '../types/xccdf'
import he from 'he'

// const alwaysArray = ['cci_item', 'reference', 'Group', 'group', 'Benchmark', 'Rule', 'title', 'rule', 'version', 'title', '@_id', 'check'];
// 'title',
const alwaysArray = ['dc-status', 'description','notice', 'front-matter', 'rear-matter', 'reference', 'plain-text', 'platform', 'metadata', 'Benchmark', 'Group', 'Rule', 'TestResult', 'Value', 'Profile', 'check', 'ident', 'rationale'];

// arrayMode: () => {
// return true;
// }//true // needs to be updated to isArray https://github.com/NaturalIntelligence/fast-xml-parser/blob/master/docs/v4/2.XMLparseOptions.md#isarray


export function convertEncodedXmlIntoJson(
encodedXml: string
Expand All @@ -14,10 +22,16 @@ export function convertEncodedXmlIntoJson(
ignoreNameSpace: true,
attributeNamePrefix: '@_',
stopNodes: ['div', 'p'],
arrayMode: true // needs to be updated to isArray https://github.com/NaturalIntelligence/fast-xml-parser/blob/master/docs/v4/2.XMLparseOptions.md#isarray
}
const parser = new XMLParser(options)
return parser.parse(encodedXml)
isArray: (tagName: string) => {
if (alwaysArray.includes(tagName)) {
return true;
} else {
return false;
}
}
};
const parser = new XMLParser(options);
return parser.parse(encodedXml);
}


Expand Down

0 comments on commit 65e199b

Please sign in to comment.