public void fromXML ( Document domdoc ) throws DocumentException { this . encoding = domdoc . getXMLEncoding ( ) ; Element rootElement = domdoc . getRootElement ( ) ; this . reference = readDocumentReference ( domdoc ) ; this . locale = rootElement . attributeValue ( "locale" ) ; if ( this . locale == null ) { // Fallback on old <language> element this . locale = readElement ( rootElement , "language" ) ; } this . defaultLanguage = readElement ( rootElement , "defaultLanguage" ) ; this . creator = readElement ( rootElement , "creator" ) ; this . author = readElement ( rootElement , AUTHOR_TAG ) ; this . contentAuthor = readElement ( rootElement , "contentAuthor" ) ; this . version = readElement ( rootElement , "version" ) ; this . parent = readElement ( rootElement , "parent" ) ; this . comment = readElement ( rootElement , "comment" ) ; this . minorEdit = readElement ( rootElement , "minorEdit" ) ; this . attachmentData = readAttachmentData ( rootElement ) ; this . isHidden = Boolean . parseBoolean ( readElement ( rootElement , "hidden" ) ) ; this . title = readElement ( rootElement , "title" ) ; this . syntaxId = readElement ( rootElement , "syntaxId" ) ; this . content = readElement ( rootElement , "content" ) ; this . datePresent = isElementPresent ( rootElement , "date" ) ; this . contentUpdateDatePresent = isElementPresent ( rootElement , "contentUpdateDate" ) ; this . creationDatePresent = isElementPresent ( rootElement , "creationDate" ) ; this . attachmentDatePresent = rootElement . selectSingleNode ( "//attachment/date" ) != null ; // Does this document contain a XWiki.TranslationDocumentClass xobject? if ( ! rootElement . selectNodes ( "//object/className[text() = 'XWiki.TranslationDocumentClass']" ) . isEmpty ( ) ) { this . containsTranslations = true ; // Record the visibility for ( Node node : rootElement . selectNodes ( "//object/className[text() = 'XWiki.TranslationDocumentClass']/../property/scope" ) ) { this . translationVisibilities . add ( node . getStringValue ( ) ) ; } } }
Parse XML document to extract document information .