XSL: Tracking elements that toggle - xslt

The following string gets encoded in my source XML using toggles, and I want it changed to nodes with formatting information. (This is XLIFF to WordprocessingML.)
"Text, bold text, bold and italics text, bold text, plain text."
Source XML:
<text>
Text
<format id="1" type="bold" />
bold text,
<format id="2" type="italics" />
bold and italics text,
<endformat id="2" />
bold text,
<endformat id="1" />
plain text.
</text>
I need:
<run>
<format></format>
<text>Text, </text>
</run>
<run>
<format><b/></format>
<text>bold text, </run>
</run>
<run>
<format><b/><i/></format>
<text>bold and italics text, </run>
</run>
<run>
<format><b/></format>
<text>bold text, </run>
</run>
<run>
<format></format>
<text>plain text.</run>
</run>
If I were using a procedural language, I'd keep a running record of what formatting is active and write out the <format> element accordingly.
But how do I do it in XSL?

Since the child nodes of text are alternating text() followed by format with symmetric endformat and text() I think you can pass a list of the nodes to xsl:call-template recursively, processing two start nodes and 2 end nodes and shortening the list by the leading 2 nodes and traling 2 nodes each time. But I am not clear about the syntax of your file so this may not be possible.

Related

Fill grouped lines with background

I want to create a grouped object with multiple lines and fill the object with a background color.
As you can see, however, the background does not respect the lines as a frame.
Is it possible to fill only the grouped object within the lines?
It's not possible using grouped lines (style will be applied to whole group which have shape of rectangle) , but you can create custom shape using Arrange > Insert > Shape. You can find description how to do that here or here. If you want to edit shape after inserting it, you can do that using Edit Shape from Style tab in format panel on right (it is also possible to edit some of draw.io shapes).
Example shape similar to your image:
<shape h="100" w="100" aspect="variable" strokewidth="inherit">
<foreground>
<path>
<move x="50" y="0" />
<line x="80" y="40" />
<line x="100" y="50" />
<line x="60" y="100" />
<line x="30" y="100" />
<line x="0" y="60" />
<close />
</path>
<fillstroke />
</foreground>
</shape>
Remeber to use <fillstroke /> or <fill /> if you want colored background.

Looking for Domino XSL help trying to find fields where the color is set to Blue

I have a very large form with hundreds of fields on it. Some are black and some are blue. I'm trying to parse the dxl using xsl to find the fields where they are set to the color blue.
i've found several xsl files to parse the dxl but I can'tfigure out how to find the field then find the previous font color='blue'
Can anyone help me with that syntax? Here is a sample of the dxl I am trying to parse:
<par def="100">
<run>
<font size="9pt" style="bold" name="Arial" pitch="variable" truetype="true" familyid="20" />
</run>
<run>
<font size="9pt" color="blue" style="bold" name="Arial" pitch="variable" truetype="true" familyid="20" />
<field type="text" kind="editable" name="DevComments">
<code event="inputtranslation">
<formula>#Trim( #ThisValue )</formula>
</code>
</field>
</run>
<compositedata type="98" prevtype="65418" nexttype="222" afterparcount="6" containertype="65418" aftercontainercount="1" afterbegincount="3">Yg4BAIQAAAAAAAAAAAA=</compositedata>
<run>
<font size="9pt" style="bold" name="Arial" pitch="variable" truetype="true" familyid="20" />
</run>
</par>

QT XML reader reads the same tag everytime

I try to read an XML file and the reader reads it well, until it reads one specific tag (the close tag of Categories) and afterwards it read this tag infinite times.
This is the xml file:
<?xml version="1.0" encoding="utf-8"?>
<MovieMain MovieName="movie1" Version="1.29746.011215">
<FrameGroups FirstFrame="START" LastFrame="END">
<GroupFramesDescription>ALL MOVIE</GroupFramesDescription>
<frames Framenumber="1" >
<ObjectsGroup Name="1">
<LeftUpCorner X="30" Y="124" Z="0" />
<RightDownCorner X="53" Y="160" Z="0" />
<InfoAtt AttName="INDEX" AttInfo="1" />
<Categories>
<Category Name="computer" Probability="0.79" />
<Category Name="pen" Probability="0.7" />
<Category Name="desktop" Probability="0.1" />
<Category Name="mug" Probability="0.09" />
</categories>
</ObjectsGroup>
</frames>
</FrameGroups>
</MarkingChanges>
<ChangesList UserName="ooo" Date="12/3/2015" ChangesetIndex="1" />
</MarkingChanges>
</MovieMain>
And this is the function that I call to read the next element:
orXmlReader->readNextStartElement();
It gives me every time the next element till the close tag of Categories and than it read it again and again (I tried a loop of 100 times...).
I hope that you will help me as soon as you can,
Thanks.
Opening tag is <Categories> and closing is </categories> , i believe that search is case sensitive. Can you try with </Categories> as closing tag?

How can I extract text before a specific character in a string using Coldfusion?

I have a string that looks like:
5137.02014-10-16T11:26:32-06:001.0.
How can I extract the text or numbers before the first period? It will not always be 4 characters.
EDIT:
After looking at the source code, it appears to be producing this:
<wddxpacket version="1.0">
<header>
<data>
<struct>
<var name="Logo">
<string></string>
</var>
<var name="ID">
<number>5137.0</number>
</var>
<var name="RLink">
<string></string>
</var>
<var name="DateCreated">
<datetime>2014-10-16T11:26:32-06:00</datetime>
</var>
<var name="showTabs">
<number>1.0</number>
</var>
</struct>
</data>
I am just trying to extract the ID which would be 5137 in this case.
Thanks!
Update:
Looks like the input is actually WDDX, rather than a plain text string. Convert it into a CF structure. Then extract the "ID" value by key. No need for parsing strings.
<!--- convert the string into a CF structure --->
<cfwddx action="WDDX2CFML"
input="#yourString#"
output="result">
<!--- grab the "ID" value --->
<cfdump var="#result.ID#">
With updated information on the structure of the data, this answer is no longer valid.
You can do this
#listfirst(my_number_string,".")#

XSLT - how to match any non-text node children?

I'm new to XSLT and I can't figure out how to get an xsl:if that matches when there are no child tags.
I want this to match:
<context>
howdy
</context>
And this not:
<context>
<child>
howdy
</child>
</context>
the relevant xpath expression should look like:
//context[not(./*)]
You could also specify count(child::*) = 0 .