Localization in c++ - c++

I am using rc files to localize my application which works fine.
Unfortunately there are is one module which uses an xml file to match the label name. The functionality of this XML file is much more than just some labels on the form but its irrelevant for this question.
The code reads the xml and constructs a form for data entry. What is the best way to localize this xml? I want to avoid having multiple versions of this file. The part of the xml looks as under
<Attribute name="Description" displayname="Summary" desc="Short Description" type="TEXT" length="32" edit="1" column="DESCRIP"/>
The displayname from above is the label on my form.
Any suggestions?

IMHO, there are 2 ways to localize the XML :
at file level : one xml file per language
at string level : you put labels in the (unique) xml files and lookup localized strings for those labels in your rc files.

Related

Can I force the XSLT collection function to treat all files as XSL?

I'm currently building an XSLT stylesheet used to document other XSLT stylesheets in a series of folders and sub-folders. My code pulls out specific details about variables, functions, etc and renders it in an output format. The sheets being read are created by a 3rd party product. Most of them have an XSL extension but some of them are proprietary extensions. I have some files with a DTCBS extension but they are just XSL stylesheets.
I'm currently loading the content of these files into a variable using the XSLT function "collection" as follows:
<xsl:variable name="Collection" select="collection(concat('file:///', encode-for-uri(replace($filePath, '\\', '/')),'?select=*.(xsl|dtcbs|xml);recurse=yes'))" as="node()*"/>
The variable works just fine if I use XSL|XML. But if I include the DTCBS extension, the variable blows up citing "the supplied value is xs:base64Binary".
If I manually put the xml declaration line at the top of my DTCBS file, the variable works fine. Those DTCBS files are auto-generated without the declaration line so I can't fix that, nor can I manually edit them each time I want to run my documenter code.
From what I can tell, because it's not an XSL extension, and the XML declaration line isn't present, the XSLT parser thinks it's base64 when it isn't.
I'm using Saxon as my XSLT parser and the Saxon documentation says it uses file extensions and http headers to detect the file type.
Does anyone know if there is a way to force collection() to treat every file as an XSL?
Tried adding the XML declaration line in the DTCBS file. This did correct the issue but I can't do this in all cases as I am trying to automate the entire thing.
I also renamed the DTCBS extension to XSL and the problem went away as well.
As well as Martin's suggestion, you can register content types with the Saxon configuration:
processor.getUnderlyingConfiguration()
.registerFileExtension("dtcbs", "application/xml");
This has been available since Saxon 9.7.
Try to add e.g. content-type=application/xml e.g. '?select=*.(xsl|dtcbs|xml);recurse=yes;content-type=application/xml'.

QT C++ Project (Creating Login with XML)

I have question about my internship project. They want me to create a basic Login page(ID, Password). I create a XML file for Username and Password. The program should check the XML file for username and password*. If they are correct it will direct to a second window. I'm stuck on processing XML file for username and password. How can read those information in XML file.
As #JarMan said, I would recommend the QXmlStreamReader. You can fill it with a file (QIODevice), QString, QByteArray, etc...
Parsing a value could e.g. look like that
xml.attributes().value( attribute ).toString();
if attribute is a QString and xml is the QXmlStreamReader.
See the doc https://doc.qt.io/qt-5/qxmlstreamreader.html
There are several ways to do it. Marris mentioned one, but another one is to have this kind of code generated automatically. The way this works is that you first write an XML Schema that describes what your XML data looks like. An introduction to the XML Schema language can be found e. g. here.
Then you use an XML Schema compiler to translate the XML Schema to C++ classes. The schema compiler will also generate code to parse an XML file into objects, meaning you don't have to write any code to deal with XML by hand. It's a purely declarative approach: declare what the data looks like, and let the computer figure out the details.

BIRT possible XSS in XLS format

I'm trying to fix an issue that exists in XLS and CSV formats and currently it's not handled by the respective BIRT emitters.
For example, using the following section in a rptdesign file, would produce an Excel file(or a CSV file to import in Excel) which opens the calculator application:
<cell id="22">
<label id="23">
<text-property name="text">=cmd|' /C calc'!A0</text-property>
</label>
</cell>
Does BIRT support a global handler to parse the BIRT model before rendering and escape such values appropriately?
Or is there perhaps another way to properly handle this?
Thank you!
I would say this is not a BIRT issue, but an Excel issue. You would have to check and escape the text yourself.

tibco xslt not accepting html script

I have to convert one xml to html page. I read that xml and mapped to transform xml. I have added html formatting tags in xslt. But it is not reflecting in page. I am getting data of xml in one line side by side. The html code not working what i have given. So any one can let me know how to transform xml to html, is there any other solution ?
yes, I have added that "tibco xslt " in title of this question ....
when working on tibco bw, I have to convert xml into html webpage; so i have used html code along with xslt transformation in xslt activity and also referenced it in transform activity. but the resulting html is not as required, all the elements of xml are coming in html side by side;
but when i used this same html code out side of tibco, it is working fine as it is showing in a well formatted table.....
Then my question is will tibco xslt execute html code or not ?
I am not too sure about using xslt transform activity for parsing a xml into html file.
Try parsing xml and then write file activity . You can alter the content of the file as per your requirement with tags and data from the parsed xml file.

OpenXML How to insert an "ID" for each paragraph?

I'm trying to manually create docx files. In fact, I create the file "document.xml" with an XSL Transformation from an XML file data.
I'll need to convert my docx into xml data file in the future. So I need to put identifiers in each paragraph. I tried naively to put my own "id" attribute on a , but of course Word removes it.
Do you have any idea how I could identify my elements of in this docx xml?
Thank you
You could try using aliased sdt blocks for paragraph identifiers.