Namespace in XML prevents extracting ID as resname

11 views
Skip to first unread message

Manuel Souto Pico

unread,
Jun 16, 2022, 1:38:42 PM6/16/22
to okapi-users
Dear all,

I'm trying to prepare the following file as XLIFF in Rainbow:

<?xml version="1.0"?>
<file xmlns="http://www.imsglobal.org/xsd/imsqti_v2p2">
<p pid="foo">Bar</p>
</file>

Of course it's a simplified version but that's enough to show the issue.

I would like to extract the value of `pid` as the resname.

Following the documentation about unique IDs here https://okapiframework.org/wiki/index.php/How_to_Create_a_Custom_Configuration_for_the_XML_Filter I am using the following okf...@custom.fprm:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<its:rules xmlns:its="http://www.w3.org/2005/11/its" xmlns:itsx="http://www.w3.org/2008/12/its-extensions" xmlns:okp="okapi-framework:xmlfilter-options" xmlns:qti="http://www.imsglobal.org/xsd/imsqti_v2p1" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.0">

<its:translateRule itsx:idValue="@pid" selector="//p" translate="yes"/>
</its:rules>

but all I get is

<?xml version="1.0" encoding="UTF-8"?>
<xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2" xmlns:okp="okapi-framework:xliff-extensions" xmlns:its="http://www.w3.org/2005/11/its" xmlns:itsxlf="http://www.w3.org/ns/its-xliff/" its:version="2.0">
<file original="SampleQTI/InputAndSelect.xml" source-language="en" target-language="gu-IN" datatype="xml">
<body>
<trans-unit id="1">
<source xml:lang="en">Bar</source>
<target xml:lang="gu-IN"></target>
</trans-unit>
</body>
</file>
</xliff>

However, if I remove the namespace from the source XML file, like so:

<?xml version="1.0"?>
<file>
<p pid="foo">Bar</p>
</file>

then I get the intended result:

<?xml version="1.0" encoding="UTF-8"?>
<xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2" xmlns:okp="okapi-framework:xliff-extensions" xmlns:its="http://www.w3.org/2005/11/its" xmlns:itsxlf="http://www.w3.org/ns/its-xliff/" its:version="2.0">
<file original="SampleQTI/InputAndSelect.xml" source-language="en" target-language="gu-IN" datatype="xml">
<body>
<trans-unit id="1" resname="foo">
<source xml:lang="en">Bar</source>
<target xml:lang="gu-IN"></target>
</trans-unit>
</body>
</file>
</xliff>

However, I think I would need to keep the namespace (it seems necessary for other ITS rules).

Could someone explain why this happens and/or suggest a solution or workaround?

Thanks in advance.
Cheers, Manuel



yves.s...@gmail.com

unread,
Jun 16, 2022, 3:48:38 PM6/16/22
to Manuel Souto Pico, okapi-users

Hi Manuel,

 

It took me a long time to see the problem.

There are actually two issues:

 

In your rule file main element you use the prefix qti to define the namespace, but in the translateRule you don’t use that prefix:

Your example: <its:translateRule itsx:idValue="@pid" selector="//p" translate="yes"/>

What you should use: <its:translateRule itsx:idValue="@pid" selector="//qti:p" translate="yes"/>

Then the rule applies to the p in that namespace. In your current rule file the rule applies to p without namespace.

 

Now even with this fix things were not working…

That’s because there is a second problem:

The namespaces are different:

Rule file: "http://www.imsglobal.org/xsd/imsqti_v2p1"

XML file: "http://www.imsglobal.org/xsd/imsqti_v2p2"

 

If you change your rule file to:

 

<?xml version="1.0" encoding="UTF-8" standalone="no"?>

<its:rules xmlns:its=http://www.w3.org/2005/11/its xmlns:itsx=http://www.w3.org/2008/12/its-extensions xmlns:okp="okapi-framework:xmlfilter-options" xmlns:qti=http://www.imsglobal.org/xsd/imsqti_v2p2 xmlns:xlink=http://www.w3.org/1999/xlink version="2.0">

<its:translateRule itsx:idValue="@pid" selector="//qti:p" translate="yes"/>

</its:rules>

 

It should give you something like this (here with Tikal):

 

<?xml version="1.0" encoding="UTF-8"?>

<xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2" xmlns:okp="okapi-framework:xliff-extensions" xmlns:its=http://www.w3.org/2005/11/its xmlns:itsxlf=http://www.w3.org/ns/its-xliff/ its:version="2.0">

<file original="test.xml" source-language="en" target-language="fr" datatype="xml" okp:inputEncoding="UTF-8" okp:configId="/C:/Dev/Okapi/dev/trunk/deployment/maven/dist_win32-x86_64/test/okf...@rules.fprm">

<body>

<trans-unit id="1" resname="foo">

<source xml:lang="en">Bar</source>

<target xml:lang="fr">Bar</target>

</trans-unit>

</body>

</file>

</xliff>

 

Hope this helps.

-yves

--
You received this message because you are subscribed to the Google Groups "okapi-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to okapi-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/okapi-users/CABm46barPaqmBejjxM0L%2BkDE-o7y%2B9_y%2B%3DgJ3JoxkYyfUaQsaQ%40mail.gmail.com.

Manuel Souto Pico

unread,
Jun 17, 2022, 3:18:08 AM6/17/22
to Yves Savourel, okapi-users
Hi Yves,

Thank you so much for your quick and useful reply. Indeed, I keep forgetting the namespace prefix... aargh.

It works now! Thanks, and have a great day.
Cheers, Manuel
Reply all
Reply to author
Forward
0 new messages