Buggy code:
@ ApplicationScoped @ Stateful public class DeusNexMachinaController { @ Inject private Logger logger ; @ Inject private PluginSettingsController pluginSettingsController ; @ Inject private MaterialUnEmbedder materialUnEmbedder ; private class EmbeddedItemHandler implements DeusNexEmbeddedItemElementHandler { public EmbeddedItemHandler ( DeusNexMachinaController deusNexMachinaController , WorkspaceNode importRoot , DeusNexDocument deusNexDocument ) { } @ Override public Node handleEmbeddedDocument ( Document ownerDocument , String title , Integer queryType , Integer resourceNo , Integer embeddedResourceNo ) { } @ Override public Node handleEmbeddedImage ( Document ownerDocument , String title , String alt , Integer width , Integer height , Integer hspace , String align , Integer resourceNo ) { } @ Override public Node handleEmbeddedAudio ( Document ownerDocument , Integer resourceNo , Boolean showAsLink , String fileName , String linkText , Boolean autoStart , Boolean loop ) { } @ Override public Node handleEmbeddedHyperlink ( Document ownerDocument , Integer resourceNo , String target , String fileName , String linkText ) { } private String getResourcePath ( Integer resourceNo ) { } private String getResourcePath ( DeusNexDocument deusNexDocument , Resource resource ) { } private String getResorceContentType ( Integer resourceNo ) { } private WorkspaceNode importRoot ; private DeusNexDocument deusNexDocument ; } private static final String LOOKUP_SETTING_NAME = "[_DEUS_NEX_MACHINA_LOOKUP_]" ; private static final String IDS_SETTING_NAME = "[_DEUS_NEX_MACHINA_IDS_]" ; @ Inject private HtmlMaterialController htmlMaterialController ; @ Inject private BinaryMaterialController binaryMaterialController ; @ Inject private WorkspaceMaterialController workspaceMaterialController ; @ Inject private WorkspaceEntityController workspaceEntityController ; @ PostConstruct public void init ( ) throws IOException { } public DeusNexDocument parseDeusNexDocument ( InputStream inputStream ) throws DeusNexException { } public void importDeusNexDocument ( WorkspaceNode parentNode , InputStream inputStream ) throws DeusNexException { } public void importFrontPageDocument ( WorkspaceEntity workspaceEntity , InputStream inputStream ) throws DeusNexException { } public void importHelpPageDocument ( WorkspaceEntity workspaceEntity , InputStream inputStream ) throws DeusNexException { } private void postProcessResources ( List < WorkspaceNode > createdNodes ) throws IOException , ParserConfigurationException , TransformerException , XPathExpressionException , SAXException { } private void postProcessHtml ( HtmlMaterial material ) throws IOException , ParserConfigurationException , TransformerException , XPathExpressionException , SAXException { StringReader htmlReader = new StringReader ( material . getHtml ( ) ) ; DOMParser parser = new DOMParser ( new HTMLConfiguration ( ) ) ; parser . setProperty ( "http:////cyberneko.org//html//properties//names//elems" , "lower" ) ; InputSource inputSource = new InputSource ( htmlReader ) ; parser . parse ( inputSource ) ; Document domDocument = parser . getDocument ( ) ; <START_BUG> List < Element > elements = DeusNexXmlUtils . getElementsByXPath ( domDocument . getDocumentElement ( ) , "////IFRAME[@data-type=\"embedded-document\"]" ) ; <END_BUG> if ( ! ( elements . isEmpty ( ) ) ) { for ( Element element : elements ) { String path = element . getAttribute ( "src" ) ; String workspaceUrlName = "" ; Pattern pattern = Pattern . compile ( "//([0-9_\\-.a-zA-Z]*)//([0-9_\\-.a-zA-Z]*)//materials//([0-9_\\-.a-zA-Z//]*).*" ) ; Matcher matcher = pattern . matcher ( path ) ; if ( matcher . matches ( ) ) { workspaceUrlName = matcher . group ( 2 ) ; path = matcher . group ( 3 ) ; WorkspaceEntity workspaceEntity = workspaceEntityController . findWorkspaceByUrlName ( workspaceUrlName ) ; WorkspaceMaterial workspaceMaterial = workspaceMaterialController . findWorkspaceMaterialByWorkspaceEntityAndPath ( workspaceEntity , path ) ; HtmlMaterial htmlMaterial = htmlMaterialController . findHtmlMaterialById ( workspaceMaterial . getMaterialId ( ) ) ; element . setAttribute ( "data-material-id" , String . valueOf ( htmlMaterial . getId ( ) ) ) ; element . setAttribute ( "data-material-type" , htmlMaterial . getType ( ) ) ; element . setAttribute ( "data-workspace-material-id" , String . valueOf ( workspaceMaterial . getId ( ) ) ) ; } } StringWriter writer = new StringWriter ( ) ; TransformerFactory transformerFactory = TransformerFactory . newInstance ( ) ; Transformer transformer = transformerFactory . newTransformer ( ) ; transformer . setOutputProperty ( OutputKeys . ENCODING , "UTF-8" ) ; transformer . setOutputProperty ( OutputKeys . OMIT_XML_DECLARATION , "yes" ) ; transformer . setOutputProperty ( OutputKeys . METHOD , "xml" ) ; transformer . setOutputProperty ( OutputKeys . INDENT , "no" ) ; transformer . transform ( new DOMSource ( domDocument ) , new StreamResult ( writer ) ) ; htmlMaterialController . updateHtmlMaterialHtml ( material , writer . getBuffer ( ) . toString ( ) ) ; } } private WorkspaceMaterialAssignmentType determineEmbeddedAssignmentType ( HtmlMaterial material ) throws DeusNexException { } private void importResource ( WorkspaceNode importRoot , WorkspaceNode parent , Resource resource , DeusNexDocument deusNexDocument , List < WorkspaceNode > createdNodes ) throws DeusNexException { } private Material createMaterial ( WorkspaceNode importRoot , Resource resource , DeusNexDocument deusNexDocument ) throws DeusNexException { } private Material createDocumentMaterial ( WorkspaceNode importRoot , fi . muikku . plugins . dnm . parser . structure . model . Document resource , DeusNexDocument deusNexDocument ) throws DeusNexException { } private Material createQueryMaterial ( WorkspaceNode importRoot , Query resource , DeusNexDocument deusNexDocument ) throws DeusNexException { } private BinaryMaterial createBinaryMaterial ( Binary resource ) { } private String parseDocumentContent ( WorkspaceNode importRoot , Element document , DeusNexDocument deusNexDocument ) throws DeusNexException { } private String parseQueryContent ( WorkspaceNode importRoot , Element document , DeusNexDocument deusNexDocument ) throws DeusNexException { } private WorkspaceFolder createFolder ( WorkspaceNode parent , Folder resource ) { } private WorkspaceNode findNode ( WorkspaceNode parent , Resource resource ) { } private void setResourceWorkspaceNodeId ( Integer resourceNo , Long workspaceNodeId ) throws IOException { } Long getResourceWorkspaceNodeId ( Integer resourceNo ) { } private void loadLookup ( ) throws IOException { } private void storeLookup ( ) throws IOException { } public void setWorkspaceEntityIdDnmId ( String dnmId , Long workspaceEntityId ) throws IOException { } public Long getWorkspaceEntityIdDnmId ( String dnmId ) { } private void storeIdMap ( ) throws IOException { } private void loadIdMap ( ) throws IOException { } private DeusNexStructureParser deusNexStructureParser ; private Properties lookupProperties ; private Map < String , Long > idMap ; }

Fix:
List < Element > elements = DeusNexXmlUtils . getElementsByXPath ( domDocument . getDocumentElement ( ) , "////iframe[@data-type=\"embedded-document\"]" ) ;