Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Namespace-prefixes of elements and attributes in XML input files are deleted #377

Closed
TobiasNx opened this issue Jul 5, 2021 · 4 comments · Fixed by #383
Closed

Namespace-prefixes of elements and attributes in XML input files are deleted #377

TobiasNx opened this issue Jul 5, 2021 · 4 comments · Fixed by #383
Assignees

Comments

@TobiasNx
Copy link
Contributor

TobiasNx commented Jul 5, 2021

If decode XML it seems that namespaces in element and attribute names are deleted:

			<mods:mods ID="duepublico_mods_00074526">
				<mods:name type="personal" xlink:type="simple">
					<mods:displayForm>Armbruster, André</mods:displayForm>
					<mods:role>
						<mods:roleTerm authority="marcrelator" type="code">aut</mods:roleTerm>
						<mods:roleTerm authority="marcrelator" type="text">Author</mods:roleTerm>
					</mods:role>
					<mods:nameIdentifier type="gnd">1081830107</mods:nameIdentifier>
					<mods:namePart type="family">Armbruster</mods:namePart>
					<mods:namePart type="given">André</mods:namePart>
				</mods:name>

FLUX:

default infile = FLUX_DIR + "mods.xml";


infile
| open-file
| decode-xml
| handle-generic-xml
| encode-xml // (or: encode-json)
| write(FLUX_DIR + "result.xml")
;

encoded as XML

				<name>
					<type>personal</type>
					<type>simple</type>
					<displayForm>
						<value>Armbruster, André</value>
					</displayForm>
					<role>
						<roleTerm>
							<authority>marcrelator</authority>
							<type>code</type>
							<value>aut</value>
						</roleTerm>
						<roleTerm>
							<authority>marcrelator</authority>
							<type>text</type>
							<value>Author</value>
						</roleTerm>
					</role>
					<nameIdentifier>
						<type>gnd</type>
						<value>1081830107</value>
					</nameIdentifier>
					<namePart>
						<type>family</type>
						<value>Armbruster</value>
					</namePart>
					<namePart>
						<type>given</type>
						<value>André</value>
					</namePart>
				</name>

or encoded as JSON

			"name": {
				"type": "personal",
				"type": "simple",
				"displayForm": {
					"value": "Armbruster, André"
				},
				"role": {
					"roleTerm": {
						"authority": "marcrelator",
						"type": "code",
						"value": "aut"
					},
					"roleTerm": {
						"authority": "marcrelator",
						"type": "text",
						"value": "Author"
					}
				},
				"nameIdentifier": {
					"type": "gnd",
					"value": "1081830107"
				},
				"namePart": {
					"type": "family",
					"value": "Armbruster"
				},
				"namePart": {
					"type": "given",
					"value": "André"
				}
			},
@TobiasNx TobiasNx added the Bug label Jul 5, 2021
@TobiasNx TobiasNx changed the title Namespaces of elements and attributes in XML input files are deleted Namespace-prefixes of elements and attributes in XML input files are deleted Aug 2, 2021
@TobiasNx
Copy link
Contributor Author

TobiasNx commented Aug 2, 2021

This is also not documented.

Also the deletion of the namespace prefix creates the problem that you cannot distinguish between:

<mods:name type="personal" xlink:type="simple">

both end up beeing named type

@dr0i dr0i self-assigned this Aug 17, 2021
dr0i added a commit that referenced this issue Aug 24, 2021
This Introduces the new parameter "emitNamespace" to GenericXMLHandler.
If set to "true" input data like "<foo:bar>" will be passed through as
"foo:bar".
For backward compatibility the default is set to "false", thus only "bar" is
emitted.

See #377.
dr0i added a commit that referenced this issue Aug 24, 2021
@dr0i
Copy link
Member

dr0i commented Aug 24, 2021

I set up a branch where your input should now result in an output preserving namespaces, like:

                                <mods:name>
                                        <type>personal</type>
                                        <xlink:type>simple</xlink:type>
                                        <mods:displayForm>
                                                <value>Armbruster, André</value>
                                        </mods:displayForm>
                                  </mods:name>

@dr0i dr0i assigned TobiasNx and unassigned dr0i Aug 24, 2021
@dr0i
Copy link
Member

dr0i commented Aug 24, 2021

In the flux you would add the parameter like handle-generic-xml(emitnamespace="true").

TobiasNx added a commit to TobiasNx/notWorkingFlux that referenced this issue Aug 24, 2021
TobiasNx added a commit to TobiasNx/notWorkingFlux that referenced this issue Aug 24, 2021
@TobiasNx
Copy link
Contributor Author

@TobiasNx TobiasNx assigned dr0i and unassigned TobiasNx Aug 24, 2021
dr0i added a commit that referenced this issue Aug 24, 2021
dr0i added a commit that referenced this issue Aug 24, 2021
dr0i added a commit to metafacture/metafacture-documentation that referenced this issue Aug 24, 2021
@acka47 acka47 linked a pull request Aug 26, 2021 that will close this issue
@dr0i dr0i closed this as completed in #383 Aug 26, 2021
@dr0i dr0i added Enhancement and removed Bug labels Aug 26, 2021
@dr0i dr0i mentioned this issue Nov 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants