Skip to content

Commit

Permalink
formatting and cleanup ns stripping check
Browse files Browse the repository at this point in the history
  • Loading branch information
jclausen committed Jan 17, 2025
1 parent 782effd commit 8faf108
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions src/main/java/ortus/boxlang/runtime/types/XML.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;

import org.apache.commons.lang3.StringUtils;

import org.w3c.dom.Document;
import org.w3c.dom.DocumentType;
import org.w3c.dom.Entity;
Expand Down Expand Up @@ -503,16 +505,23 @@ public XML getFirstChildOfName( String childName ) {
NodeList children = node.getChildNodes();
for ( int i = 0; i < children.getLength(); i++ ) {
Node child = children.item( i );
if ( child.getNodeType() == Node.ELEMENT_NODE
//@formatter:off
if (
child.getNodeType() == Node.ELEMENT_NODE
&&
( child.getNodeName().equalsIgnoreCase( childName )
(
child.getNodeName().equalsIgnoreCase( childName )
||
// For some reason `getPrefix` is not always populated with parsed xml, so we have to manually split the name
( child.getNodeName().split( ":" ).length > 1
(
child.getPrefix() != null
&&
child.getNodeName().split( ":" )[ 1 ].equalsIgnoreCase( childName ) ) ) ) {
StringUtils.replace( child.getNodeName(), child.getPrefix() + ":", "" ).equalsIgnoreCase( childName )
)
)
) {
return new XML( child );
}
//@formatter:on
}
return null;
}
Expand Down

0 comments on commit 8faf108

Please sign in to comment.