Is there a FluentAssertions Should for checking an XML document versus an expected document? - fluent-assertions

Is there a FluentAssertions "Should.Be" for checking an entire XML document versus an expected document?

Use xDocument.BeEquivalentTo(otherxDocument) to a deep comparison. See the [definition[(https://github.com/fluentassertions/fluentassertions/blob/master/Src/FluentAssertions/Xml/XDocumentAssertions.cs#L116 ) from the source code.

Related

How can I detect org.docx4j.wml.instrText when parsing DOCX with docx4j?

I want to pars a docx file with docx4j library.
I need to detect org.docx4j.wml.instrText objects but actually it returns org.docx4j.wml.Text instead of org.docx4j.wml.instrText.
I found a solution that was working with older version of this library here:
http://www.docx4java.org/forums/docx-java-f6/can-i-just-don-t-load-contents-of-w-instrtext-into-text-t193.html
Actually this solution:
((javax.xml.bind.JAXBElement)((org.docx4j.wml.Text) o).getParent()).getName().getLocalPart()
But with the latest update it does not work. Could you please tell me what changes I have to make on this code?
Actually it make a type casting error that can not convert org.docx4j.wml.R to JAXBElement.
Thanks in advance.
The parent of the Text object, given by:
((org.docx4j.wml.Text) o).getParent()
is, as the error says, a org.docx4j.wml.R, which you can't cast to JAXBElement.
To identify your object in this case, try:
((javax.xml.bind.JAXBElement)o).getName().getLocalPart()

Apostrophe is converting as '

I have a table in which there is a column of type long.
In this column, we have stored the email responses. Now the problem which i am facing while querying business component which is on this table, is that the character ' is automatically getting converted to '
As shown in example below:
Value in column:
We've noticed some unusual usage on your phone.
Value coming while querying the Business Component:
We've noticed some unusual usage on your phone.
Although if i query in database directly, i am able to see ' correctly.
Can anyone suggest how this is happening ?
Thanks
The above link is related to Siebel.
So i will place my answer w.r.t Siebel. There is templates for communicating users in CRM.
Now if you do not mark HTML Template, then it will not convert the content of the body in UTF-8 format.
Since the HTML Type was unmarked in your case, speical character was not getting converted.
Mark it and your problem will be solved.
The template from which this field was picking up the value, we not in HTML Template format. For handling special characters like ', this property need to be marked.
Detailed info here : ExternalLink

equivalent of normalize function of DOM in JDOM

Can some tell me the function similar to normalize() of DOM in JDOM? I actually want to normalize the XML content and serialise it through XMLSerializer.
Thank You
Sam
Sandeep.
JDOM does not have a direct 'normalize' concept. Writing one would not be particularly hard, though. On the other hand, your intention is to output the XML in some format, and all the JDOM Output mechanisms will normalize the data for you.
So, for example, if you want to output the JDOM document as plain XML text, you can use the XMLOutputter class in org.jdom2.output and use an appropriate org.jdom2.output.Format instance (say, Format.getPrettyFormat() - do not use getRawFormat() as the raw formatter will not normalize the output at all).
In addition to outputting the JDOM document as text-based XML, you can also output to a DOM document, a SAX even stream, and even StAX streams. Each of these will produce a 'Normalized' output.
So, what you want to do (probably), is to:
Document mudoc = .....;
XMLOutputter xout = new XMLOutputter(Format.getPrettyFormat());
xout.output(mydoc, somestream);
Rolf

Find references of Path Variables used in ISM file

I have one ISM file created using Installshield. In Path Variables Explorer, I can see some variables defined. How can find if they are used anywhere in the ISM ? I want to remove variables if they are unused.
I am using Installshield 11.5 Adminstudio.
Thanks in Advance.
---Sambhaji
I wrote a program that did something similar only it was looking for unused string table entries. You can read about it at:
Use Linq to XML to Clean up ISString Tables
It would only take a few tweaks to change the query to look at the table that holds ISPathVariables.
Sambhaji,
ISM files may be binaries or XML, make sure you are using the XML format.
I'm not sure if the option is the same in InstallShield 11.5, but in InstallShield 12, you have to go to General Information-->Project Properties-->Project File Format.
I understand that the Binary format is a bit faster than XML, but in order to keep my projects under version control I prefer the XML format.
There is one simple way to find references of variable or properties.
Go to Additional Tools -> Direct Editor -> Tables
Just click on Tables and press Ctrl+F (Search option). And type the variable/property you want to search & hit enter.
It will show the reference of variables/properties. Press F3 to see next occurances.

How to get SQL query to not escape HTML data returned in query

I have the following SQL query....
select AanID as '#name', '<![CDATA[' + Answer + ']]>' from AuditAnswers for XML PATH('str'), ROOT('root')
which works wonderfully but the column 'Answer' can sometimes have HTML markup in it. The query automatically escapes this HTML from the 'Answer' column in the generated XML. I don't want that. I will be wrapping this resulting column in CDATA so the escaping is not necessary.
I want the result to be this...
<str name="2"><![CDATA[<DIV><DIV Style="width:55%;float:left;">Indsfgsdfg]]></str>
instead of this...
<str name="2"><![CDATA[<DIV><DIV Style="width:55%;float:left;">In</str>
Is there a function or other mechanism to do this?
Selecting anything "FOR XML" escapes any pre-existing XML so that it will not break the consistency of the XmlDocument. The first example line you gave is considered to be improperly formed XML, and will not be able to be loaded by an XmlDocument object, as well as most parsers. I would consider restructuring what you're trying to do so that you can have a more efficient solution.
You can use for xml explicit and the cdata directive:
select
1 as tag,
null as parent,
AanID as [str!1!name],
Answer as [str!1!!cdata]
from AuditAnswers
for xml explicit
You can specify that the output be treated as CDATA when using EXPLICIT mode XML queries. See:
Using EXPLICIT Mode
and
Example: Specifying the CDATA Directive
What would be the benefit of having <[CDATA[ <div></div> ]]> over having <div></div> in your database output? To me, it looks like you would have a properly escaped HTML fragment in your XML output in both cases, and reading it back with a decent XML parser should give you the unescaped original version in both cases.