diff --git a/test/test_lidoTool.py b/test/test_lidoTool.py index fdd78c8..e4563e2 100644 --- a/test/test_lidoTool.py +++ b/test/test_lidoTool.py @@ -25,8 +25,9 @@ def test_saxon() -> None: # print(xsl["zml2lido"]) lt.saxon(src=lt.src, xsl=xsl["zml2lido"], output="test.lido.xml") + def test_saxon_umlaut() -> None: lt = LidoTool(src="ä.xml") assert str(lt.src == "ä.xml") lido_fn = lt.zml2lido() - print(f"{lido_fn=}") \ No newline at end of file + print(f"{lido_fn=}") diff --git a/zml2lido/__init__.py b/zml2lido/__init__.py index cb501c5..4693011 100644 --- a/zml2lido/__init__.py +++ b/zml2lido/__init__.py @@ -100,7 +100,7 @@ def saxon(): "-x", "--xsl", help="(xslt) transformation filename", required=True ) args = parser.parse_args() - m = LidoTool(src=args.source) + m = LidoTool(src=args.source) m.saxon(xsl=args.xsl, output=args.output) @@ -112,7 +112,7 @@ def validate(): # query570068-chunk283.lido.xml # query570068-chunk284.lido.xml m = LidoTool(src=args.input) - m.validate() # raises if does not validate + m.validate() # raises if does not validate def vocmap(): diff --git a/zml2lido/data/xsl/zml2lido/event-Herstellung.xsl b/zml2lido/data/xsl/zml2lido/event-Herstellung.xsl index 16c2662..0492cb6 100644 --- a/zml2lido/data/xsl/zml2lido/event-Herstellung.xsl +++ b/zml2lido/data/xsl/zml2lido/event-Herstellung.xsl @@ -37,7 +37,8 @@ 'Stecher', 'Stecherin', 'Stecher*in', 'Verfasser', 'Verfasserin', 'Verfasser*in', 'Zeichner', 'Zeichnerin', 'Zeichner*in'"/> - + + + + - + diff --git a/zml2lido/data/xsl/zml2lido/titleWrap.xsl b/zml2lido/data/xsl/zml2lido/titleWrap.xsl index 4af6889..6af8321 100644 --- a/zml2lido/data/xsl/zml2lido/titleWrap.xsl +++ b/zml2lido/data/xsl/zml2lido/titleWrap.xsl @@ -10,6 +10,7 @@ + @@ -29,9 +30,36 @@ + + + + + + titleLanguageOrigin ist vom CCC-Portal definierter Wert + + + titleLanguageOrigin + + + + + + + + + + diff --git a/zml2lido/lidoTool.py b/zml2lido/lidoTool.py index 7722001..1c69a80 100644 --- a/zml2lido/lidoTool.py +++ b/zml2lido/lidoTool.py @@ -226,10 +226,10 @@ def validateSingle(self, *, src: Path): self.schema.assert_(doc) # raises error when not valid return src - def zml2lido(self, *, src:str|Path|None=None, xslt="zml2lido") -> Path: + def zml2lido(self, *, src: str | Path | None = None, xslt="zml2lido") -> Path: if src is None: src = self.src - #print(f"ZML2LIDO {xslt}") + # print(f"ZML2LIDO {xslt}") if self.chunks: print(" with chunks") for chunkFn in self.loopChunks(src=self.src): @@ -311,10 +311,14 @@ def firstChunkName(self, *, src: str | Path): # print(f"***firstChunkName {firstFn}") return firstFn - def saxon(self, *, output: str | Path, xsl: str | Path, src: str | Path | None = None) -> None: + def saxon( + self, *, output: str | Path, xsl: str | Path, src: str | Path | None = None + ) -> None: """ - New: src is optional. - + New: src is optional (for the LidoTool's method). + + saxon could also be a function outside of this class. + lc = LidoTool(src="ere.xml") lc.saxon(xsl="test.xsl", output="out.xml") lc.saxon(src="other.xml", xsl="test.xsl", output="out.xml") @@ -329,14 +333,14 @@ def saxon(self, *, output: str | Path, xsl: str | Path, src: str | Path | None = raise SyntaxError("ERROR: xsl file does not exist!") # https://stackoverflow.com/questions/78468764 - xml_file_name=Path(src).absolute().as_uri() + xml_file_name = Path(src).absolute().as_uri() orig = Path.cwd() with PySaxonProcessor(license=False) as proc: xsltproc = proc.new_xslt30_processor() executable = xsltproc.compile_stylesheet(stylesheet_file=str(xsl)) xml = proc.parse_xml(xml_file_name=xml_file_name) - os.chdir(self.script_dir) + os.chdir(self.script_dir) # so that saxon finds vocmap.xml result_tree = executable.apply_templates_returning_file( xdm_node=xml, output_file=str(output) ) @@ -394,18 +398,21 @@ def _prepareOutdir(self) -> Path: if re.match(r"\d\d\d\d\d\d", self.src.parent.name): outdir = sdataP / self.src.parents[1].name / self.src.parent.name elif self.src.parent.name == "sdata": + print("_outdir:Case2") outdir = sdataP - #raise SyntaxError( - # """ERROR: Don't use an src file inside of sdata. + # raise SyntaxError( + # """ERROR: Don't use an src file inside of sdata. # Use a subdirectory instead!""" - #) + # ) else: - outdir = sdataP / self.src.parent.name + # should write in sdata/ccc for example, which may be pwd + print(f"_outdir:Case3 {self.src.parent.resolve().name}") + outdir = sdataP / self.src.parent.resolve().name if not outdir.exists(): print(f"Making new dir {outdir}") outdir.mkdir(parents=True, exist_ok=False) - #print(f" outdir {outdir}") + # print(f" outdir {outdir}") return outdir def _sanitize(self, *, src: str | Path) -> Path: