Meaning of absent <target> element in XLIFF - xliff

According to "A. XLIFF Tree Structure" of XLIFF Specification 1.2 <trans-unit> element always has a single <source> element but can have 0 or 1 <target> element. Yet nowhere in the specification I found an explanation what would the absence of <target> element mean? Would it mean that translation is an empty string or that translation is the same text as contained in <source> element?
And in what part of specification (or some other source) that meaning is explained?

There are several reasons for the absence of <target> element and they can be different in various implementation of XLIFF format.
Sdl Trados Studio uses missing <target> elements in units with translate="no" attribute (defined in Xliff namespace) - e.g. when source contains only tags.
It could also mean that the translation unit is not segmented yet, but as I said I think it depends on implementation.

Related

Is there a name for dot-separated case?

We have camelCase, PascalCase, snake_case, and kebab-case. Is there a name for dot.separated.case?
Maybe there isn't a name for it, maybe I can't properly word my question for Google, but I can't find anything for it.
The "dot case format" or "dot notation" is the common denotation here. The format often used in property files, resource-bundles or yaml-files.
It's basically a convention that makes it easier to see what properties are related.
For example:
person.title="Title"
person.surname="Surname"
person.job.description="Some description"
You can easily collect similar properties by filtering the prefix like 'person.' to only see the properties defined for a person.
The dot.case format is also used in maven to name properties. E.g:
${project.build.directory}
See also the maven pom properties

Simplexml get path from variable

Is there a way to pass the path to a simplexml node as a variable?
This is what I tried:
//set the path to the node in a variable
$comp = 'component->structuredBody->component';
echo count($xml->component->structuredBody->component); //=== 13
echo count($xml->$comp); //===0
echo count($xml->{$comp});//===0
What you need is XPath, and more specifically SimpleXML's xpath() method. Instead of traversing using PHP's -> operator, you would traverse using XPath's / operator, but otherwise, could achieve exactly the effect you wanted:
$comp = 'component[1]/structuredBody[1]/component';
echo count( $xml->xpath($comp) );
You might think that this could be simplified to 'component/structuredBody/component', but that would find all possible paths matching the expression - that is if there are multiple structuredBody elements, it will search all of them. That might actually be useful, but it is not equivalent to $xml->component->structuredBody->component, which is actually shorthand for $xml->component[0]->structuredBody[0]->component.
A few things to note:
Unlike most operations with SimpleXML, the result is an array, not another SimpleXML object (think of it as a set of search results). It is therefore vital that you check it is not empty before accessing element 0 as an object.
As you can see in the example above, XPath counts from 1, not 0. I don't know why, but it's caught me out before, so I thought I'd warn you.
The library SimpleXML is built on supports only XPath 1.0;
examples you see online for XPath 2.0 may not work.
XPath 1.0 has no notion of a "default namespace", and SimpleXML doesn't automatically register namespace prefixes for use in XPath, so if you're working with namespaces, you need to use registerXPathNamespace().

Explanation of $ in Mule MEL

I cannot find any documentation around the use of $ in MEL other than a couple of lines here
You can refer to any Java class by its fully qualified name or if it
is one of the classes in the automatically-imported Java classes, by
its unqualified name. References use the same dot notation as in Java,
except that you must use $ rather than a dot to refer to a nested
class.
I can find a couple of examples here
JSON processing MEL has no direct support for JSON. The
json-to-object-transformer can turn a JSON payload into a hierarchy of
simple data structures that are easily parsed with MEL. For example,
the following uses a filtered projection to build the equivalent of
the
$..[?
(#.title=='Moby Dick')].price JSON path expression:
<json:json-to-object-transformer returnClass="java.lang.Object" />
<expression-transformer
expression="#[($.price in message.payload if $.title == 'Moby Dick')[0]]" />
I want to understand in which cases does the $ get used...
$ comes from MVEL, the language underlying MEL.
$ serves as the placeholder for the element being filtered. It is
actually a regular variable that exists inside the context of the
projection. You can also use it to return the current element in the
projection to the representative list.
Reference: http://mvel.codehaus.org/MVEL+2.0+Projections+and+Folds#MVEL2.0ProjectionsandFolds-Filters

Can I index source code using Lucene?

I would like to index source code using Lucene. The source code has already been pre-analysed using a compiler plugin. The output of the compiler is a list of IDs that appear in the source code. Each ID includes information about
the module the ID was defined in (as opposed to used in),
the source span where the ID appears (i.e. line:col-line:col), and
whether the ID is defined at this location or merely used here.
For example, given this source code module (in pseudo-code)
module MyModule
from MyOtherModule import bar
foo = ...
print bar
here's what the compiler might output when compiling MyModule:
MyModule.foo,3:1-3:3,definition
MyOtherModule.bar,4:7-4:9,use
Note how all IDs that appear in the output are fully qualified, even though they might not appear that way in the source. This is why we use a compiler, it allows us to do more exact code search than just purely text-based search.
Question: Is it possible to write a custom tokenizer and analyzer that indexes the compiler output shown above in a way that the metadata (i.e. the fully qualified ID and whether the ID was defined or used at the given location) is kept an available when scoring the documents?
To be more precise, I'd like each term to be associated with the module where it was defined (e.g. foo would have associated metadata: defining module=MyModule). I want each posting in the posting list to store whether this particular appearance of an ID was a definition or a use of that ID.
In addition, I'd like to have Lucene store the non-qualified ID as synonyms for the qualified ID. This would allow users to search for "foo" and retrieve all documents that contain the IDs "Module1.foo" and "Module2.foo".
It's probably easier to put the various attributes into Lucene fields, so that you can query like:
parse module:MyModule use:yes
which would return only hits on 'parse' in 'MyModule' where 'parse' was used rather than defined.

Could xsl:variable be defined twice with same name

Could xsl:variable be defined twice with same name in same scope.
For code similar to the following:
<xsl:template match="\">
<table>
<tr><td>
<xsl:variable name="status" select="normal"/>
</td></tr>
<tr><td>
<xsl:variable name="status" select="failed"/>
</td></tr>
</table>
</xsl:template>
Maybe it depends on browse's type. What is the standard?
First, two variables never have the same scope. Even if they are both global, the scope of the variable excludes its own select expression, so the scope of the two variables is different.
Second, in your example the scope of the two variables isn't even overlapping. Each variable is confined to its own containing td element.
For two global variables, the rule is that you can have two variables with the same name provided they have different import precedence, in which case all references are treated as references to the one with higher precedence.
If one variable is local and the other is global, then the local variable wins if it is in scope.
If you have two local variables with overlapping scope, this is an error in XSLT 1.0, but is permitted in XSLT 2.0; within the overlap area, the variable with smaller scope wins.
It is an error if two or more top-level variables (outside any template) have the same name.
Similarly it is an error if two or more variables within the same template have the same name.
But it is allowable for a variable within a template to shadow a variable of the same name at the top level.
There is no clash between variables unless their scopes (the parts of the stylesheet where the variables are visible) overlap. The scope of a variable inside a template includes its following sibling elements and their descendants. The scope of a top-level variable is everywhere in the stylesheet after that variable.
I have found the key.
MSXML 3.0 supports only XDR schemas, it does not support XSD schemas. MSXML 4.0, MSXML 5.0, and MSXML 6.0 support XSD schemas.