Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Message tree drag-and-drop has incorrect syntax when namespaces / bound prefixes are present #3108

Closed
rbeckman-nextgen opened this issue May 11, 2020 · 9 comments
Milestone

Comments

@rbeckman-nextgen
Copy link
Collaborator

@rbeckman-nextgen rbeckman-nextgen commented May 11, 2020

If the actual node you're dragging has a namespace reference (like <S:Body>), the drag-and-drop E4X syntax is incorrect. Currently it pastes msg['S:Body'], which will not work in actual message processing.

One option is to just always include wildcards, like msg.*::['Body']. That way it should always work regardless of what namespace is present.

The more "correct" way to do it would be to actually define the namespace and reference it (like "var S = new Namespace(...)" and then msg.S::['Body']), but that would require creating two steps, one JavaScript to define the namespace, and then the actual Mapper / Message Builder step. This might be too confusing/complex, so maybe it's better to leave that for MIRTH-1110.

Imported Issue. Original Details:
Jira Issue Key: MIRTH-3196
Reporter: narupley
Created: 2014-03-20T14:54:33.000-0700

@rbeckman-nextgen rbeckman-nextgen added this to the 3.4.0 milestone May 11, 2020
@rbeckman-nextgen
Copy link
Collaborator Author

@rbeckman-nextgen rbeckman-nextgen commented May 11, 2020

Added a patch for this. If an element contains a namespace we add a wildcard in dot notation.

Imported Comment. Original Details:
Author: eduardoa
Created: 2016-01-29T13:13:26.000-0800

@rbeckman-nextgen
Copy link
Collaborator Author

@rbeckman-nextgen rbeckman-nextgen commented May 11, 2020

If json properties can have a colon then this would probably need to exclude the change for json data type.

Imported Comment. Original Details:
Author: eduardoa
Created: 2016-01-29T13:32:51.000-0800

@rbeckman-nextgen
Copy link
Collaborator Author

@rbeckman-nextgen rbeckman-nextgen commented May 11, 2020

Updated patch so that it only applies to XML serialization.

As of now I think we just need to decide if we would like to apply this change. The patch I uploaded will wildcard the namespace. RIght now the drag and drop with namespaces does not work at all, but always adding a wildcard is not 100%. Adding the namespace correctly might be pretty tricky since there would need to be some extra js tied to the drag and drop.

One possibility is to wildcard the namespace and notify the user that the wildcard has been applied. Then we could still leave the correct implementation for MIRTH-1110

Imported Comment. Original Details:
Author: eduardoa
Created: 2016-02-29T15:12:27.000-0800

@rbeckman-nextgen
Copy link
Collaborator Author

@rbeckman-nextgen rbeckman-nextgen commented May 11, 2020

rev 7956:
We now assign nodes types as we iterate from child to parent to add more versatility to namespace drag and drop. The drag and drop can drag nodes, attribute or namespace attributes so the user should be able to correctly do these now.
If a node has a namespace then will wildcard it. If an ancestor of the node has an implicit namespace then we will also append a wildcard. The only exception to this is if the implicit namespace is on the root node, we actually set this to the default namespace in JavaScriptBuilder.

Imported Comment. Original Details:
Author: eduardoa
Created: 2016-03-25T15:14:54.000-0700

@rbeckman-nextgen
Copy link
Collaborator Author

@rbeckman-nextgen rbeckman-nextgen commented May 11, 2020

Here are the type of things we have to test for this ticket. Keep in mind that we are just testing the drag and drop so any old code won't be affected.

This is a good xml to test that prefixes are being correctly spotted and wildcarded.
<h:html xmlns:h="http://www.w3.org/HTML/1998/html4" xmlns:xdc="http://www.xml.com/books" test="test"> <h:head test="testttt" xmlns:xdct="http://www.xml.com/bookst"> <h:title>Book Review</h:title> </h:head> <h:body> <xdc:bookreview> <xdc:title>XML: A Primer</xdc:title> <h:table xmlns="http://www.w3.org/1999/xhtml"> <h:tr align="center"> <h:td>Author</h:td> <h:td>Price</h:td> <h:td>Pages</h:td> <h:td>Date</h:td> </h:tr> <h:tr align="left"> <h:td> <xdc:author>Simon St. Laurent</xdc:author> </h:td> <h:td> <xdc:price>31.98</xdc:price> </h:td> <h:td> <xdc:pages>352</xdc:pages> </h:td> <h:td> <xdc:date>1998/01</xdc:date> </h:td> </h:tr> </h:table> </xdc:bookreview> </h:body> </h:html>

And the test would look something like this:
//test logger.info(msg['@test'].toString()); //http://www.w3.org/HTML/1998/html4 logger.info(msg.namespace('h').toString()); //testttt logger.info(msg.*::['head']['@test'].toString()); //Book Review logger.info(msg.**::['head'].**::['title'].toString()); //<xdc:bookreview xmlns:xdc="http://www.xml.com/books">xml stuff here</xdc:bookreview> logger.info(msg.**::['body'].**::['bookreview'].toString()); //http://www.w3.org/1999/xhtml logger.info(msg.**::['body'].*::['bookreview'].**::['table'].namespace('').toString()); //Author logger.info(msg.**::['body'].*::['bookreview'].*::['table'].*::['tr'][0].**::['td'][0].toString()); //Pages logger.info(msg.**::['body'].*::['bookreview'].*::['table'].*::['tr'][0].**::['td'][2].toString()); //left logger.info(msg.**::['body'].*::['bookreview'].*::['table'].**::['tr'][1]['@align'].toString());

This is an example of when the root node has an implicit namespace so no wildcards should be added
<test xmlns="http://www.w3.org/1999/xhtml"> <node> <test2> <node2>test2</node2> </test2> </node> </test>

//"http://www.w3.org/1999/xhtml logger.info(msg.namespace('').toString()) //test2 logger.info(msg['node']['test2']['node2'].toString());

This is an example of when an implicit namespace is found deeper in the document then wildcards must be added to that element and any children nodes only.
<test> <node> <test2 xmlns="http://www.w3.org/1999/xhtml"> <node2>test2</node2> </test2> </node> </test>

//http://www.w3.org/1999/xhtml logger.info(msg['node'].*::['test2'].namespace('').toString()); //test2 logger.info(msg['node'].**::['test2'].**::['node2'].toString()); //<test2 xmlns="http://www.w3.org/1999/xhtml"><node2>test2</node2></test2> logger.info(msg['node'].toString());

We also need to make sure that all the JSON dragging still works since we did touch that code:
{ "test" : "testString", "testArray" : [7, 4, 3, 4] }

//testString logger.info(msg['test']); //7, 4, 3, 4 logger.info(msg['testArray'].toString()); //7 logger.info(msg['testArray'][0]); //4 logger.info(msg['testArray'][1]);

Imported Comment. Original Details:
Author: eduardoa
Created: 2016-03-25T15:22:30.000-0700

@rbeckman-nextgen
Copy link
Collaborator Author

@rbeckman-nextgen rbeckman-nextgen commented May 11, 2020

Some of the new things that were added was that if you drag and drop a namespace attribute from the tree it will actually now drag a namespace function. For implicit namespaces it will drag .namespace('') for prefixed namespaces it will drag .namespace('prefix').

Also, it would be good to add more testing with actual HL7v3 (CCD) messages.

Imported Comment. Original Details:
Author: eduardoa
Created: 2016-03-25T15:27:42.000-0700

@rbeckman-nextgen
Copy link
Collaborator Author

@rbeckman-nextgen rbeckman-nextgen commented May 11, 2020

It looks like namespaced attributes aren't being handled correctly. Take the following XML:

<ClinicalDocument xmlns="urn:hl7-org:v3" xmlns:voc="urn:hl7-org:v3/voc" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:hl7-org:v3 CDA.xsd"/>

Then try to get out the "schemaLocation" attribute. The drag-and-drop creates:

msg.*::['schemaLocation'].toString()

But that doesn't work. This does though:

msg.@*::['schemaLocation'].toString()

Imported Comment. Original Details:
Author: narupley
Created: 2016-03-28T09:10:56.000-0700

@rbeckman-nextgen
Copy link
Collaborator Author

@rbeckman-nextgen rbeckman-nextgen commented May 11, 2020

You definitely warned me about that, sorry. I added that to the drag and drop now(rev 7959).

Imported Comment. Original Details:
Author: eduardoa
Created: 2016-03-28T12:12:12.000-0700

@rbeckman-nextgen
Copy link
Collaborator Author

@rbeckman-nextgen rbeckman-nextgen commented May 11, 2020

Verified that message tree drag-and-drop will now handle namespaces correctly. Before a node would have been dropped in and the namespace prefix / tag name would have been combined together, like msg\['soapenv:Body'\]. However now the tree will detect when a namespace is required and if so, includes an E4X wildcard, like msg.*::\['Body'\].

This does mean that if there are multiple nodes at the same level with the same tag name but different namespaces, the wildcard may incorrectly reference both of them rather than a specific node. But at least this is better than it was before (would have just errored out before). If a user wants to reference a specific namespace, this can still easily be done by swapping out the "*" with the appropriate variable.

The drag-and-drop also handles xmlns attributes correctly now, using the E4X namespace method and passing in the prefix. Attributes with specific bound namespace prefixes are also correctly handled.

Imported Comment. Original Details:
Author: narupley
Created: 2016-03-28T13:45:25.000-0700

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
1 participant
You can’t perform that action at this time.