How to get the doctype declaration using DOM on Xerces 2.8 - doctype

I am trying to add the DOCTYPE declaration to an output XML file using Xerces 2.8
I am using DOMDocument* doc1 = implementation->createDocument(); to create the document
and I want to add the doctype from doc to doc1.
I could obtain the doctype from doc as follow:
DOMDocumentType* document_type = doc->getDoctype();
However, I can not pass document_type to the function createDocument().
Does anyone has an example of how to do this?
Thank you,
Gilmer

You have to set the "http://xml.org/sax/properties/lexical-handler" property of your Xerces instance to an object of type "LexicalHandler". You will be informed about any events over the "startDTD" callback. This is at least true for Java. Should be identical for C.

Related

Cannot detect test object in Katalon using xpath

I want to find a test object with an xpath starting with id("foo")/. I tried with the following line:
findTestObject("MyPath", [('id'), 'foo'])
but it doesn't work. I've already tried the most obvious solution, that is checking the property xpath and using
findTestObject("MyPath")
but it didn't work because apparently part of the xpath changes at runtime.
Try to find your element via Selenium WebElement.
Example:
def driver = DriverFactory.getWebDriver()
WebElement elem = driver.findElement(ById.id('elementID'))

Property Mapping Exception in Helhum upload example

I am using helhum File Upload Demo to upload the images. But currently i got below error.
Exception while property mapping at property path "images.0":Property "name" was not found in target object of type "XXXX\XXXXX\Domain\Model\FileReference
Please help here.. How can i move forward.
Thanks in advace.
If you followed the example extension, you are maybe missing the registration of UploadedFileReferenceConverter and ObjectStorageConverter in your ext_localconf.php. Took me a day to find that one:
ext_localconf.php
\TYPO3\CMS\Extbase\Utility\ExtensionUtility::registerTypeConverter('Vendor\\EXT\\Property\\TypeConverter\\UploadedFileReferenceConverter');
\TYPO3\CMS\Extbase\Utility\ExtensionUtility::registerTypeConverter('Vendor\\EXT\\Property\\TypeConverter\\ObjectStorageConverter');
In the initializeUpdateAction (or initializeCreateAction) you have to use the name of the parameter in the updateAction (or createAction) as argument.
If your updateAction looks like this:
public function updateAction(\Classname $yourObject)
You have to call the helhum function with the argument:
$this->setTypeConverterConfigurationForImageUpload('yourObject');
As a small hint for later problems: In the setTypeConverterConfigurationForImageUpload function you should register your own file attributes if they are not named image and/or imageCollection.0 like in the example.

Getting properties from AEM multifieldpanel dialog stops working when a second entry is added

I have created an AEM Dialog which prompts the user for a set of links and labels.
These links and labels are stored in a jcr node and are used to generate a menu.
To avoid having to create a custom xtype, I am using the acs-commons multifieldpanel solution, which enables me to nest children under the fieldConfig node.
This works great with only 1 Label/Link pair, but when I add a second one - the property cannot be fetched anymore, since instead of a String, it returns the String hashcode.
The property generated by the multifieldpanel in the jcr node is of type String and is filled correctly when inspecting in CRXDE. The problem occurs when I try to fetch the value from within a Sightly HTML file.
Code
Dialog:
Definitions.js:
"use strict";
use(function () {
var CONST = {
PROP_URLS: "definitions",
};
var json = granite.resource.properties[CONST.PROP_URLS];
log.error(json);
return {
urls: json
};
});
Log output
1 element in multifieldpanel
jcr node variable content
definitions: {"listText": "facebook", "listPath": "/content/en"}
log output
{"linkText":"facebook","linkPath":"/content/en"}
Multiple elements in multifieldpanel
jcr node variable content
definitions: {"listText": "facebook", "listPath": "/content/en"},{"listText": "google", "listPath": "/content/en"}
log output
[Ljava.lang.String;#7b086b97
Conclusion
Once the multifieldpanel has multiple components and stores it, when accessing the property the node returns the String hashcode instead of the value of the property.
A colleague has pointed out that I should use the MultiFieldPanelFunctions class to access the properties, but we are using HTML+Sightly+js and are trying to avoid .jsp files at all cost. In JavaScript, this function is not available. Does anyone have any idea how to solve this issue?
That is because, when there is a single item in the multifield, it returns a String, where as it returns a String[] when there is more than a single item configured.
Use the following syntax to read the property as a String array always.
var json = granite.resource.properties[CONST.PROP_URLS] || [];
Additionally, you can also use TypeHints to make sure your dialog saves the value as String[] always, be it single item or multiple items that is configured.
Don't forget that the use() in JS is compiled into Java Byte code and if you are reading Java "primitives", make sure you convert them to JS types. It's part of the Rhino subtleties.
On another note, I tend to not use the granite.* because they are not documented no where, I use the Sightly global objects instead https://docs.adobe.com/content/docs/en/aem/6-0/develop/sightly/global-objects.html
To access properties, I use properties.get("key")
Hope this help.

mshtml fireevent onchange not firing

I am unable to fire an "onchange" event in mshtml. Can you please tell me what I am doing wrong here.
HTMLSelectElement element = (HTMLSelectElement)this.HTMLDocument.all.item(controlId, 0);
IHTMLElement e = element as IHTMLElement;
IHTMLDocument4 doc = e.document as IHTMLDocument4;
object dummy = null;
object eventObj = doc.CreateEventObject(ref dummy);
HTMLSelectElementClass se = element as HTMLSelectElementClass;
se.FireEvent("onchange", ref eventObj);
I am getting variable "se" as null. I got this piece of code from another link http://www.itwriting.com/phorum/read.php?3,1507
Can anyone help me with this.
Thanks,
Sam
Runtime Callable Wrapper objects generated by COM calls like HTMLDocument.all.item can translate interface casting to QueryInterface calls. But the RCW does not know how to convert to a managed class like HTMLSelectElementClass, thus it returns null.
Instead of casting to HTMLSelectElementClass, cast to IHTMLElement3 to call fireEvent.
By the way, your code does not work in IE11 mode as document.all is deprecated. Use IHTMLDocument3::getElementById instead.
I had tried all those which Sheng mentioned but didn't work.
This issue was solved by injecting javascript code for "onchange" and executing it. It worked.

HATEOAS link to method with optional requestparams

I want to link to a method that has the following signature:
public SomeResponse getSomeObjects(#RequestParam(value = "foo", defaultValue = "bar") Foo fooValue)
Now I want the link to look like this:
http://myhost/api/someobjects
I tried using methodOn from Spring HATEOAS's ControllerLinkBuilder as seen below:
discoverResponse.add(linkTo(methodOn(SomeController.class).getSomeObjects(null)).withRel("someobjects"))
But it doesn't lead to the desired link because a ?foo is added at its end. How can I achieve the above objective?
Since backward compatibility is such an issue for you, you could always manually construct your Link objects like so:
discoverResponse.add(new Link(baseUri() + "/someobjects", "someobjects"));
The other option would be to fork Spring HATEOAS on GitHub, build the project yourself, and change the way defaults are handled in ControllerLinkBuilder. I don't really know how you'd expect an out-of-context Link builder to be able to differentiate between whether it should advertise an optional parameter. In the HATEOAS world, if the parameter isn't included, the client doesn't know about it. So why even have the optional parameter?
I know there are 7 years gone now, but I had a similar problem today which lead me here. In spring hateoas 1.1.0 the behavior is slightly different, instead it will generate URI-Templates by default for non-required #RequestParams:
http://myhost/api/someobjects{?foo}
If you don't want them in your link, you can just expand it
Map<String, Object> parameters = new HashMap<>();
parameters.put("foo", null);
link = link.expand(parameters);
It will result in the desired URL
http://myhost/api/someobjects