C# 클래스 Bloom.Book.HtmlDom

HtmlDom manages the lower-level operations on a Bloom XHTML DOM. These doms can be a whole book, or just one page we're currently editing. They are actually XHTML, though when we save or send to a browser, we always convert to plain html.
파일 보기 프로젝트 열기: BloomBooks/BloomDesktop 1 사용 예제들

Private Properties

프로퍼티 타입 설명
AddKnownStyleIfMissing void
Ensure void
EnsureIdsAreUnique void
GetClasses IEnumerable
MakeJavascriptElement System.Xml.XmlElement
MigrateChildren void
MigrateEditableData string
RemoveStyleSheetIfFound void

공개 메소드들

메소드 설명
AddCalendarFoldClassToBody ( XmlDocument dom ) : void
AddClass ( XmlElement e, string className ) : void
AddClassIfMissing ( XmlElement element, string className ) : void
AddCreationType ( string mode ) : void

The Creation Type is either "translation" or "original". This is used to protect fields that should normally not be editable in one or the other. This is a bad name, and we know it!

AddHidePlaceHoldersClassToBody ( XmlDocument dom ) : void
AddJavascriptFile ( string pathToJavascript ) : void
AddJavascriptFileToBody ( string pathToJavascript ) : void
AddPublishClassToBody ( ) : void
AddPublishClassToBody ( XmlDocument dom ) : void

By including this class, we help stylesheets do something different for edit vs. publish mode.

AddRightToLeftClassToBody ( XmlDocument dom ) : void
AddRtlDir ( XmlElement e ) : void
AddStyleSheet ( string path ) : void
AddStyleSheetIfMissing ( string path ) : void
AddStylesheetFromAnotherBook ( HtmlDom sourceBookDom, HtmlDom targetBookDom ) : void
ApplyXSLT ( string pathToXSLT ) : XmlDocument

Applies the XSLT, and returns an XML dom

Clone ( ) : HtmlDom
ConvertHtmlBreaksToNewLines ( string html ) : string
FindChildWithClass ( XmlElement parent, string classVal ) : XmlElement

Find the first child of parent that has the specified class as (one of) its classes.

FindFontsUsedInCss ( string cssContent, HashSet result, bool includeFallbackFonts ) : void

Finds a list of fonts used in the given css

GatherDataBookLanguages ( ) : List

Gives all the unique language codes found in datadiv elements that have data-book

GetAttributeValue ( XmlElement elt, string name ) : string
GetBookSetting ( string key ) : MultiTextBase
GetImageElementUrl ( ElementProxy imgOrDivWithBackgroundImage ) : UrlPathString

Gets the url for the image, either from an img element or any other element that has an inline style with background-image set.

GetImageElementUrl ( GeckoHtmlElement imageElement ) : UrlPathString

Gets the url for the image, either from an img element or any other element that has an inline style with background-image set.

GetImageElementUrl ( XmlElement imageElement ) : UrlPathString

Gets the url for the image, either from an img element or any other element that has an inline style with background-image set.

GetMetaValue ( string name, string defaultValue ) : string
GetOrCreateDataDiv ( XmlNode dom ) : XmlElement
GetTemplateStyleSheets ( ) : IEnumerable
HasMetaElement ( string name ) : bool
HtmlDom ( ) : System
HtmlDom ( XmlDocument domToClone ) : System
HtmlDom ( string xhtml ) : System
IsImgOrSomethingWithBackgroundImage ( XmlElement element ) : bool
MergeClassesIntoNewPage ( XmlElement sourcePage, XmlElement targetPage, string classesToDrop ) : void

Blindly merge the classes from the source into the target.

ProcessPageAfterEditing ( XmlElement destinationPageDiv, XmlElement edittedPageDiv ) : void
RemoveBookSetting ( string key ) : void
RemoveClassesBeginingWith ( XmlElement xmlElement, string classPrefix ) : void
RemoveDirectorySpecificationFromStyleSheetLinks ( ) : void
RemoveExtraBookTitles ( ) : void

Fix BL-2789, where Tok Pisin and Indonesian would show up in the source bubble for book titles, saying the equivalent of "new book" in each language. BasicBook doesn't have that anymore, but this cleans it up in books made from old shells.

RemoveExtraContentTypesMetas ( ) : void
RemoveFileProtocolFromStyleSheetLinks ( ) : void

gecko 11 requires the file://, but modern firefox and chrome can't handle it. Checked also that IE10 works without it.

RemoveMetaElement ( string name ) : void
RemoveMetaElement ( string oldName, Func read, Action write ) : void

Can be called without knowing that the old exists. If it already has the new, the old is just removed. This is just for migration.

RemoveModeStyleSheets ( ) : void
RemoveRtlDir ( XmlElement e ) : void
RemoveXMatterStyleSheets ( ) : void

The chosen xmatter changes, so we need to clear out any old ones

SafeSelectNodes ( string xpath ) : XmlNodeList
SelectChildImgAndBackgroundImageElements ( XmlElement element ) : XmlNodeList
SelectSingleNode ( string xpath ) : XmlElement
SelectSingleNodeHonoringDefaultNS ( string xpath ) : XmlElement
SetBookSetting ( string key, string writingSystemId, string form ) : void
SetElementFromUserStringPreservingLineBreaks ( XmlElement node, string form ) : void
SetImageElementUrl ( ElementProxy imgOrDivWithBackgroundImage, UrlPathString url ) : void

Sets the url attribute either of an img (the src attribute) or a div with an inline style with an background-image rule

SortStyleSheetLinks ( ) : void
UpdateMetaElement ( string name, string value ) : void

creates if necessary, then updates the named in the head of the html

UpdatePageDivs ( ) : void
UpdatePageToTemplate ( HtmlDom pageDom, XmlElement templatePageDiv, string pageId ) : void
ValidateBook ( string descriptionOfBookForErrorLog ) : string

비공개 메소드들

메소드 설명
AddKnownStyleIfMissing ( XmlNode child ) : void
Ensure ( bool passes, string message, StringBuilder builder ) : void
EnsureIdsAreUnique ( HtmlDom dom, string elementTag, List ids, StringBuilder builder ) : void
GetClasses ( XmlElement element ) : IEnumerable
MakeJavascriptElement ( string pathToJavascript ) : XmlElement
MigrateChildren ( XmlElement page, string parentClass, XmlElement newPage ) : void

For each div in the page which has the specified class, find the corresponding div with that class in newPage, and replace its contents with the contents of the source page. Also inserts any needed styles we know about.

MigrateEditableData ( XmlElement page, XmlElement template, string lineage ) : string

Replace page in its parent with an element which is a clone of template, but with the contents of page transferred as far as possible. Retain the id of the page. Set its lineage to the supplied value

RemoveStyleSheetIfFound ( string path ) : void

메소드 상세

AddCalendarFoldClassToBody() 공개 정적인 메소드

public static AddCalendarFoldClassToBody ( XmlDocument dom ) : void
dom System.Xml.XmlDocument
리턴 void

AddClass() 공개 정적인 메소드

public static AddClass ( XmlElement e, string className ) : void
e System.Xml.XmlElement
className string
리턴 void

AddClassIfMissing() 공개 정적인 메소드

public static AddClassIfMissing ( XmlElement element, string className ) : void
element System.Xml.XmlElement
className string
리턴 void

AddCreationType() 공개 메소드

The Creation Type is either "translation" or "original". This is used to protect fields that should normally not be editable in one or the other. This is a bad name, and we know it!
public AddCreationType ( string mode ) : void
mode string
리턴 void

AddHidePlaceHoldersClassToBody() 공개 정적인 메소드

public static AddHidePlaceHoldersClassToBody ( XmlDocument dom ) : void
dom System.Xml.XmlDocument
리턴 void

AddJavascriptFile() 공개 메소드

public AddJavascriptFile ( string pathToJavascript ) : void
pathToJavascript string
리턴 void

AddJavascriptFileToBody() 공개 메소드

public AddJavascriptFileToBody ( string pathToJavascript ) : void
pathToJavascript string
리턴 void

AddPublishClassToBody() 공개 메소드

public AddPublishClassToBody ( ) : void
리턴 void

AddPublishClassToBody() 공개 정적인 메소드

By including this class, we help stylesheets do something different for edit vs. publish mode.
public static AddPublishClassToBody ( XmlDocument dom ) : void
dom System.Xml.XmlDocument
리턴 void

AddRightToLeftClassToBody() 공개 정적인 메소드

public static AddRightToLeftClassToBody ( XmlDocument dom ) : void
dom System.Xml.XmlDocument
리턴 void

AddRtlDir() 공개 정적인 메소드

public static AddRtlDir ( XmlElement e ) : void
e System.Xml.XmlElement
리턴 void

AddStyleSheet() 공개 메소드

public AddStyleSheet ( string path ) : void
path string
리턴 void

AddStyleSheetIfMissing() 공개 메소드

public AddStyleSheetIfMissing ( string path ) : void
path string
리턴 void

AddStylesheetFromAnotherBook() 공개 정적인 메소드

public static AddStylesheetFromAnotherBook ( HtmlDom sourceBookDom, HtmlDom targetBookDom ) : void
sourceBookDom HtmlDom
targetBookDom HtmlDom
리턴 void

ApplyXSLT() 공개 메소드

Applies the XSLT, and returns an XML dom
public ApplyXSLT ( string pathToXSLT ) : XmlDocument
pathToXSLT string
리턴 System.Xml.XmlDocument

Clone() 공개 메소드

public Clone ( ) : HtmlDom
리턴 HtmlDom

ConvertHtmlBreaksToNewLines() 공개 정적인 메소드

public static ConvertHtmlBreaksToNewLines ( string html ) : string
html string
리턴 string

FindChildWithClass() 공개 정적인 메소드

Find the first child of parent that has the specified class as (one of) its classes.
public static FindChildWithClass ( XmlElement parent, string classVal ) : XmlElement
parent System.Xml.XmlElement
classVal string
리턴 System.Xml.XmlElement

FindFontsUsedInCss() 공개 정적인 메소드

Finds a list of fonts used in the given css
public static FindFontsUsedInCss ( string cssContent, HashSet result, bool includeFallbackFonts ) : void
cssContent string
result HashSet
includeFallbackFonts bool true to include fallback fonts, false to include only the first font in each font family
리턴 void

GatherDataBookLanguages() 공개 메소드

Gives all the unique language codes found in datadiv elements that have data-book
public GatherDataBookLanguages ( ) : List
리턴 List

GetAttributeValue() 공개 정적인 메소드

public static GetAttributeValue ( XmlElement elt, string name ) : string
elt System.Xml.XmlElement
name string
리턴 string

GetBookSetting() 공개 메소드

public GetBookSetting ( string key ) : MultiTextBase
key string
리턴 MultiTextBase

GetImageElementUrl() 공개 정적인 메소드

Gets the url for the image, either from an img element or any other element that has an inline style with background-image set.
public static GetImageElementUrl ( ElementProxy imgOrDivWithBackgroundImage ) : UrlPathString
imgOrDivWithBackgroundImage ElementProxy
리턴 UrlPathString

GetImageElementUrl() 공개 정적인 메소드

Gets the url for the image, either from an img element or any other element that has an inline style with background-image set.
public static GetImageElementUrl ( GeckoHtmlElement imageElement ) : UrlPathString
imageElement GeckoHtmlElement
리턴 UrlPathString

GetImageElementUrl() 공개 정적인 메소드

Gets the url for the image, either from an img element or any other element that has an inline style with background-image set.
public static GetImageElementUrl ( XmlElement imageElement ) : UrlPathString
imageElement System.Xml.XmlElement
리턴 UrlPathString

GetMetaValue() 공개 메소드

public GetMetaValue ( string name, string defaultValue ) : string
name string
defaultValue string
리턴 string

GetOrCreateDataDiv() 공개 정적인 메소드

public static GetOrCreateDataDiv ( XmlNode dom ) : XmlElement
dom System.Xml.XmlNode
리턴 System.Xml.XmlElement

GetTemplateStyleSheets() 공개 메소드

public GetTemplateStyleSheets ( ) : IEnumerable
리턴 IEnumerable

HasMetaElement() 공개 메소드

public HasMetaElement ( string name ) : bool
name string
리턴 bool

HtmlDom() 공개 메소드

public HtmlDom ( ) : System
리턴 System

HtmlDom() 공개 메소드

public HtmlDom ( XmlDocument domToClone ) : System
domToClone System.Xml.XmlDocument
리턴 System

HtmlDom() 공개 메소드

public HtmlDom ( string xhtml ) : System
xhtml string
리턴 System

IsImgOrSomethingWithBackgroundImage() 공개 정적인 메소드

public static IsImgOrSomethingWithBackgroundImage ( XmlElement element ) : bool
element System.Xml.XmlElement
리턴 bool

MergeClassesIntoNewPage() 공개 정적인 메소드

Blindly merge the classes from the source into the target.
public static MergeClassesIntoNewPage ( XmlElement sourcePage, XmlElement targetPage, string classesToDrop ) : void
sourcePage System.Xml.XmlElement
targetPage System.Xml.XmlElement
classesToDrop string
리턴 void

ProcessPageAfterEditing() 공개 정적인 메소드

public static ProcessPageAfterEditing ( XmlElement destinationPageDiv, XmlElement edittedPageDiv ) : void
destinationPageDiv System.Xml.XmlElement
edittedPageDiv System.Xml.XmlElement
리턴 void

RemoveBookSetting() 공개 메소드

public RemoveBookSetting ( string key ) : void
key string
리턴 void

RemoveClassesBeginingWith() 공개 정적인 메소드

public static RemoveClassesBeginingWith ( XmlElement xmlElement, string classPrefix ) : void
xmlElement System.Xml.XmlElement
classPrefix string
리턴 void

RemoveDirectorySpecificationFromStyleSheetLinks() 공개 메소드

public RemoveDirectorySpecificationFromStyleSheetLinks ( ) : void
리턴 void

RemoveExtraBookTitles() 공개 메소드

Fix BL-2789, where Tok Pisin and Indonesian would show up in the source bubble for book titles, saying the equivalent of "new book" in each language. BasicBook doesn't have that anymore, but this cleans it up in books made from old shells.
public RemoveExtraBookTitles ( ) : void
리턴 void

RemoveExtraContentTypesMetas() 공개 메소드

public RemoveExtraContentTypesMetas ( ) : void
리턴 void

RemoveFileProtocolFromStyleSheetLinks() 공개 메소드

gecko 11 requires the file://, but modern firefox and chrome can't handle it. Checked also that IE10 works without it.
public RemoveFileProtocolFromStyleSheetLinks ( ) : void
리턴 void

RemoveMetaElement() 공개 메소드

public RemoveMetaElement ( string name ) : void
name string
리턴 void

RemoveMetaElement() 공개 메소드

Can be called without knowing that the old exists. If it already has the new, the old is just removed. This is just for migration.
public RemoveMetaElement ( string oldName, Func read, Action write ) : void
oldName string
read Func
write Action
리턴 void

RemoveModeStyleSheets() 공개 메소드

public RemoveModeStyleSheets ( ) : void
리턴 void

RemoveRtlDir() 공개 정적인 메소드

public static RemoveRtlDir ( XmlElement e ) : void
e System.Xml.XmlElement
리턴 void

RemoveXMatterStyleSheets() 공개 메소드

The chosen xmatter changes, so we need to clear out any old ones
public RemoveXMatterStyleSheets ( ) : void
리턴 void

SafeSelectNodes() 공개 메소드

public SafeSelectNodes ( string xpath ) : XmlNodeList
xpath string
리턴 System.Xml.XmlNodeList

SelectChildImgAndBackgroundImageElements() 공개 정적인 메소드

public static SelectChildImgAndBackgroundImageElements ( XmlElement element ) : XmlNodeList
element System.Xml.XmlElement
리턴 System.Xml.XmlNodeList

SelectSingleNode() 공개 메소드

public SelectSingleNode ( string xpath ) : XmlElement
xpath string
리턴 System.Xml.XmlElement

SelectSingleNodeHonoringDefaultNS() 공개 메소드

public SelectSingleNodeHonoringDefaultNS ( string xpath ) : XmlElement
xpath string
리턴 System.Xml.XmlElement

SetBookSetting() 공개 메소드

public SetBookSetting ( string key, string writingSystemId, string form ) : void
key string
writingSystemId string
form string
리턴 void

SetElementFromUserStringPreservingLineBreaks() 공개 정적인 메소드

public static SetElementFromUserStringPreservingLineBreaks ( XmlElement node, string form ) : void
node System.Xml.XmlElement
form string
리턴 void

SetImageElementUrl() 공개 정적인 메소드

Sets the url attribute either of an img (the src attribute) or a div with an inline style with an background-image rule
public static SetImageElementUrl ( ElementProxy imgOrDivWithBackgroundImage, UrlPathString url ) : void
imgOrDivWithBackgroundImage ElementProxy
url UrlPathString
리턴 void

SortStyleSheetLinks() 공개 메소드

public SortStyleSheetLinks ( ) : void
리턴 void

UpdateMetaElement() 공개 메소드

creates if necessary, then updates the named in the head of the html
public UpdateMetaElement ( string name, string value ) : void
name string
value string
리턴 void

UpdatePageDivs() 공개 메소드

public UpdatePageDivs ( ) : void
리턴 void

UpdatePageToTemplate() 공개 메소드

public UpdatePageToTemplate ( HtmlDom pageDom, XmlElement templatePageDiv, string pageId ) : void
pageDom HtmlDom
templatePageDiv System.Xml.XmlElement
pageId string
리턴 void

ValidateBook() 공개 메소드

public ValidateBook ( string descriptionOfBookForErrorLog ) : string
descriptionOfBookForErrorLog string
리턴 string