How can I detect org.docx4j.wml.instrText when parsing DOCX with docx4j? - 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()

Related

Object name contains more than the maximum prefixes allowed

I have seen a lot of questions about this but I couldn't find the correct answer for me which works.
The object which triggers the problem is like
test123.de.company.com.Database.dbo.Table
Test123.de.company.com
is the database Server.
Object name contains more than the maximum prefixes allowed
I have tried to write it like this [test123.de.company.com].Database.dbo.Table just like [test123.de.company.com].[Database].[dbo].[Table]
Can you tell me what's wrong with this?
Please try this:
["test123.de.company.com"].[Database].[dbo].[Table]
OP also encountered a new problem after implementing this solution above. OP said:
Thank you! This worked for me. To be more precise, the join is for a
view and if I save/close and then later get back to the design option
the quote marks are removed and there is [test123.de.company.com] left
over and the error returns. Is there a way to keep them fixed?
Otherwise if I change anything I always have to add the quote marks
again and again
Then with the help of DaleK that problem also was solved. DaleK:
Don't use the design option, script it as alter instead

Twisted.web File directory listing issues

I'm trying to use Twisted in a web-app, and I'm coming across an interesting issue. I'm very new to Twisted, so I'm not sure if I'm seeing a bug in Twisted, or if I just am not using it correctly.
Theoretically from the example, a File resource object can be use to both serve files from a directory, as well as provide the directory listing. So assuming I have the variables (port, reportsDir) defined elsewhere before the code snippet, I do the following:
rootResource = Resource()
rootResource.putChild("reports", File(reportsDir))
reactor.listenTCP(port, Site(rootResource))
reactor.run(installSignalHandlers=False)
Now, when I access '/reports' on my host I get a message "Request did not return bytes" in my browser with a bunch of stuff that was obviously produced by twisted, but also contains a print of a u'.....' string literal, which in fact has the directory listing in it. So the DirectoryLister is obviously creating the listing HTML, but it isn't seeing as valid by something in Twisted. It doesn't seem to like the unicode string; which was in fact produced by Twisted itself.
Do I need to set some other configuration item to get it to convert the unicode string to the necessary bytes object (or whatever), or some other approach?
Many thanks,
-D
Well, it seems like the issue is that Python will promote any string to unicode if any source string on a format was unicode. In my case, "reportsDir" was unicode because it came from a XML file, and that set it down the error path.
Changing the above line:
rootResource.putChild("reports", File(reportsDir))
to:
rootResource.putChild("reports", File(reportsDir.encode('ascii', 'ignore')))
fixed the issue. I would however suggest that the Twisted developers do a check for unicode in the constructor for File, or in the DirectoryLister simply check for unicode, and if it is then return the ascii-encoded version.

How to combine Wix variables

I can use "!(bind.property.ProductVersion)" to set for example the UpgradeVersion\#Minimum attribute. Works fine.
But now I want to set that attribute to something like:
"!(bind.property.ProductVersion.Major).!(bind.property.ProductVersion.Minor).0.0"
But that does not work.
I get this error: The UpgradeVersion/#Maximum attribute's value, '!(bind.property.ProductVersion.Major).!(bind.property.ProductVersion.Minor).0.0', is not a valid version. Legal version values should look like 'x.x.x.x' where x is an integer from 0 to 65534.
Any ideas how I can get this to work?
Regards, Jaap
Unfortunately, it appears the version attribute is only allowed to have a single binder variable to replace the whole string. It doesn't support the scenario you describe. However, it seems like it should. You could file a bug at http://wixtoolset.org/bugs

AS2 addCallback Type mismatch

So I don't get this at all. When I put
ExternalInterface.addCallback('startppt', null,"PlayPPT");
I get Type mismatch. However if i put
ExternalInterface.addCallback('startppt',"PlayPPT");
It takes it fine. Doesn't work when I try to call the function. I used JQuery, normal Javascript just about everything. I think it has something to do with this issue but not certain. THIS IS ACTIONSCRIPT 2 and I check the publishing settings. Any ideas or suggestions would be awesome thanks!
I realized that it should be
ExternalInterface.addCallBack('startppt', null, PlayPPT);
It wasn't the null as mismatch it was the last part I was sending a string when it was expecting a function.

What's the correct format to extract an attribute from an element of some id using selenium.getAttribute()?

I've tried tracking down the appropriate syntax to extract an attribute using selenium.getAttribute(someXPath), and while I've come across many examples, nothing seems to work. From what I can tell, standard xpath syntax, such as:
//*[#id='someID']
doesn't work. What's the correct format to extract an attribute from an element of some id?
So it seems as if that format is almost correct. The correct string would be
//*[#id="someId"]#someAttribute
Another solution is to use
"someId#someAttribute"
which actually is "better" as the former can generate errors for IE.
Also, it seems that when an element contains no attributes at all, the error message is "attributeValue is null" instead of the normal "Element / attribute not found".