Skip to content

Commit 0b4e10d

Browse files
authored
Merge pull request #193 from meaningfy-ws/feature/TED-552
Removed all xpaths property from XMLMetadata
2 parents b4f42a8 + 65605a1 commit 0b4e10d

4 files changed

Lines changed: 8 additions & 33 deletions

File tree

ted_sws/core/model/metadata.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ class XMLMetadata(Metadata):
2727
Stores the metadata of an XMLManifestation.
2828
"""
2929
unique_xpaths: List[str] = None
30-
xpaths: List[str] = None
3130

3231

3332
class LanguageTaggedString(NamedTuple):

ted_sws/data_sampler/services/notice_xml_indexer.py

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
from ted_sws.resources import XSLT_FILES_PATH
1212

1313
UNIQUE_XPATHS_XSLT_FILE_PATH = "get_unique_xpaths.xsl"
14-
XPATHS_XSLT_FILE_PATH = "get_xpaths.xsl"
1514
XSLT_PREFIX_RESULT = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
1615

1716

@@ -29,7 +28,7 @@ def index_notice_by_id(notice_id: str, mongodb_client: MongoClient):
2928
notice_repository.update(notice=notice)
3029

3130

32-
def index_notice(notice: Notice, xslt_transformer=None, unique=True) -> Notice:
31+
def index_notice(notice: Notice, xslt_transformer=None) -> Notice:
3332
"""
3433
This function selects unique XPath from XMlManifestation from a notice and indexes notices with these unique XPath.
3534
:param notice:
@@ -42,20 +41,16 @@ def index_notice(notice: Notice, xslt_transformer=None, unique=True) -> Notice:
4241
fp.write(notice.xml_manifestation.object_data.encode("utf-8"))
4342
xml_path = pathlib.Path(fp.name)
4443
xslt_path = XSLT_FILES_PATH
45-
if unique:
46-
xslt_path /= UNIQUE_XPATHS_XSLT_FILE_PATH
47-
else:
48-
xslt_path /= XPATHS_XSLT_FILE_PATH
44+
xslt_path /= UNIQUE_XPATHS_XSLT_FILE_PATH
45+
4946
if xslt_transformer is None:
5047
xslt_transformer = XMLPreprocessor()
5148
result = xslt_transformer.transform_with_xslt_to_string(xml_path=xml_path,
5249
xslt_path=xslt_path)
5350
xpaths = result[len(XSLT_PREFIX_RESULT):].split(",")
5451
xml_metadata = XMLMetadata()
55-
if unique:
56-
xml_metadata.unique_xpaths = xpaths
57-
else:
58-
xml_metadata.xpaths = xpaths
52+
xml_metadata.unique_xpaths = xpaths
53+
5954
notice.set_xml_metadata(xml_metadata=xml_metadata)
6055

6156
return notice

ted_sws/notice_validator/adapters/xpath_coverage_runner.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,10 +109,10 @@ def coverage_notice_xpath(self, notices: List[Notice], mapping_suite_id) -> XPAT
109109
if self.mongodb_client is not None:
110110
xpaths = get_unique_xpaths_covered_by_notices([notice.ted_id], self.mongodb_client)
111111
else:
112-
notice = index_notice(notice, self.xslt_transformer, False)
112+
notice = index_notice(notice, self.xslt_transformer)
113113

114-
if notice.xml_metadata and notice.xml_metadata.xpaths:
115-
xpaths = notice.xml_metadata.xpaths
114+
if notice.xml_metadata and notice.xml_metadata.unique_xpaths:
115+
xpaths = notice.xml_metadata.unique_xpaths
116116

117117
notice_xpaths[notice.ted_id] = self.based_xpaths(xpaths, self.base_xpath)
118118
xpaths_list += notice_xpaths[notice.ted_id]

ted_sws/resources/xslt_files/get_xpaths.xsl

Lines changed: 0 additions & 19 deletions
This file was deleted.

0 commit comments

Comments
 (0)