Special Chars In Xml Datasource S’abonner

0
Avatar
Legacy Poster

Goodmorning,
I'm developing a software that produces an XML used by BarTender as datasource.

I did some unlucky tests to find out how to write special characters in field values.
As for HTML i've always used html entities, but it seems that BarTender doesn't understand them.

I need to pass symbols like ">", "<", and also accented vowes but, for accented vowes there is not problem using UTF-8 charset, for the grater than and less than symbols i need a solution, otherwise XML structure will be invalid.

My XML is something like this (here i paste only one variable):

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

<!DOCTYPE labels SYSTEM "label.dtd">
<labels _FORMAT="C:\BarTender\test.btw" _JOBNAME="test1" _QUANTITY="1" _PRINTERNAME="Datamax I-4206_1">
<label>
<variable name="EFFICIENCY">100%</variable>
</label>
</labels>[/code]

Value for "EFFICIENCY" variable in some cases contains ">" and/or "<". Then i tryed the following syntax (html entities):

[code]<variable name="EFFICIENCY">&gt;80</variable>[/code]

But BarTender prints exactly the entity (i.e. "&gt;" is not [i]converted[/i] in > but is printed as is).
Also with the entity number nothing changes:

[code]<variable name="EFFICIENCY">&# 49;80</variable>[/code]

[b]***[/b] Posting the code above I had to add a space between &# and 49; because otherwise the forum converts it with the greater than symbol. The test was done without the space!

Is there a way to resolve this problem maintaining the XML datasource?
I don't know other ways to pass html entities, here is the document i used as reference: http:// www.w3schools.com/tags/ref_entities.asp

Thanks in advance and sorry if my english is not the best.

1 commentaires

0
Avatar
Shotaro Ito
Modérateur
Actions pour les commentaires Permalien

Hi Massimo,
your XML format looks different from BarTender XML Script, so I assume you have a custom software to read XML file and print format.
[b]BarTender Enterprise Automation edition[/b] has its own XML script to specify format and files, and it handles predefined entities like "&gt;" and "&lt;" properly.

Example of BarTender XML script. (default extension is *.btxml)
[xml]
<?xml version="1.0" encoding="utf-8"?>
<XMLScript Version="2.0">
<Command>
<Print>
<Format CloseAtEndOfJob="true">C:\XMLSample1.btw</Format>
<PrintSetup>
<Printer>Zebra TLP-3844Z</Printer>
<IdenticalCopiesOfLabel>3</IdenticalCopiesOfLabel>
</PrintSetup>
<NamedSubString Name="EFFICIENCY">
<Value>&gt;100%</Value>
</NamedSubString>
</Print>
</Command>
</XMLScript>
[/xml]
It especially works well with Automated printing by Commander.
For detail and usage of BarTender XML Script, please refer to BarTender online help > Automating Bartender > Automation with BarTender XML Script.

In your case, I assume your custom application doesn't handle predefined entities like "&gt;" which you could ask the developer of the application.
One simple workaround is, whenever you find "&gt;" in datasource, replace that by ">" in VB script.
In BarTender, Text object's datasource > More options > VB Script, in OnProcessData script, set code like
[code]Value = Replace(Value, "&gt;",">")
Value = Replace(Value, "&lt;","<")[/code]

Hope that helps!

Vous devez vous connecter pour laisser un commentaire.