ZPT-Sharp  v1.0.0
Zope Page Templates for .NET
 All Classes Namespaces Functions Variables Enumerations Enumerator Properties
CSF.Zpt.DocumentProviders.ZptXmlLinqElement Class Reference

Implementation of ZptElement based on documents parsed using System.Xml.Linq. More...

Inheritance diagram for CSF.Zpt.DocumentProviders.ZptXmlLinqElement:
Collaboration diagram for CSF.Zpt.DocumentProviders.ZptXmlLinqElement:

Public Member Functions

override string ToString ()
 Returns a System.String that represents the current ZptXmlLinqElement. More...
 
override bool Equals (ZptElement other)
 Determines whether the specified CSF.Zpt.Rendering.ZptElement is equal to the current CSF.Zpt.DocumentProviders.ZptXmlLinqElement. More...
 
override int GetHashCode ()
 Serves as a hash function for a CSF.Zpt.DocumentProviders.ZptXmlLinqElement object. More...
 
override IZptElement ReplaceWith (IZptElement replacement)
 Replaces the current element in its respective DOM with the given replacement. More...
 
override IZptElement[] ReplaceWith (string content, bool interpretContentAsStructure)
 Replaces the current element instance with the given content. More...
 
override void ReplaceChildrenWith (string content, bool interpretContentAsStructure)
 Removes all children of the current element instance and replaces them with the given content. More...
 
override IZptElement InsertBefore (IZptElement existing, IZptElement newChild)
 Inserts a new child element into the current element's child elements. The new child will be the previous sibling before a given existing child. More...
 
override IZptElement InsertAfter (IZptElement existing, IZptElement newChild)
 Inserts a new child element into the current element's child elements. The new child will be the next sibling after a given existing child. More...
 
override IZptElement GetParentElement ()
 Gets the element which is the parent of the current instance. More...
 
override IZptElement[] GetChildElements ()
 Gets a collection of the child elements from the current source element. More...
 
override IZptAttribute[] GetAttributes ()
 Gets a collection of the attributes present upon the current element. More...
 
override IZptAttribute GetAttribute (ZptNamespace attributeNamespace, string name)
 Gets an attribute which matches the given criteria, or a null reference is no matching attribute is found. More...
 
override void SetAttribute (ZptNamespace attributeNamespace, string name, string value)
 Sets the value of an attribute. More...
 
override void RemoveAttribute (ZptNamespace attributeNamespace, string name)
 Removes a named attribute. More...
 
override IZptElement[] SearchChildrenByAttribute (ZptNamespace attributeNamespace, string name)
 Recursively searches the children of the current instance, returning a collection of elements which have an attribute matching the given criteria. More...
 
override void PurgeAttributes (ZptNamespace attributeNamespace)
 Recursively searches for attributes with a given namespace or prefix and removes them from their parent element. More...
 
override void PurgeElements (ZptNamespace elementNamespace)
 Recursively searches for elements with a given namespace or prefix and removes them using the Omit behaviour. More...
 
override void AddCommentBefore (string comment)
 Adds a new comment to the DOM immediately before the current element. More...
 
override void AddCommentInside (string comment)
 Adds a new comment to the DOM inside the current element as its first child. More...
 
override void AddCommentAfter (string comment)
 Adds a new comment to the DOM immediately after the current element. More...
 
override IZptElement Clone ()
 Clone this instance into a new Element instance, which may be manipulated without affecting the original. More...
 
override IZptElement[] Omit ()
 Omits the current element, replacing it with its children. More...
 
override void Remove ()
 Removes the current element from the DOM. More...
 
override void RemoveAllChildren ()
 Removes all child elements from the current element. More...
 
override bool IsInNamespace (ZptNamespace nSpace)
 Determines whether or not the current instance is in the specified namespace. More...
 
override bool IsFromSameDocumentAs (IZptElement other)
 Determines whether this instance is from same document as the specified element. More...
 
override IZptDocument CreateDocumentFromThisElement ()
 Creates a new IZptDocument which contains only the current element and its children. More...
 
 ZptXmlLinqElement (XNode node, ISourceInfo sourceFile, IZptDocument ownerDocument, bool isRoot=false, bool isImported=false)
 Initializes a new instance of the CSF.Zpt.DocumentProviders.ZptXmlLinqElement class. More...
 
- Public Member Functions inherited from CSF.Zpt.Rendering.ZptElement
ISourceInfo GetSourceInfo ()
 Gets information about the source of the current element. More...
 
override bool Equals (object obj)
 Determines whether the specified System.Object is equal to the current CSF.Zpt.Rendering.ZptElement. More...
 
virtual bool Equals (IZptElement obj)
 Determines whether the specified CSF.Zpt.Rendering.IZptElement is equal to the current CSF.Zpt.Rendering.ZptElement. More...
 
virtual IZptElement[] GetElementChain ()
 Gets an ordered element chain, starting with the current element and including all of its parent elements from closest to furthest ancestors. More...
 
virtual void SetAttribute (string name, string value)
 Sets the value of an attribute. More...
 
virtual void RemoveAttribute (string name)
 Removes a named attribute. More...
 
virtual IZptElement SearchAncestorsByAttribute (ZptNamespace attributeNamespace, string name)
 Recursively searches upwards in the DOM tree, returning the first (closest) ancestor element which has an attribute matching the given criteria. More...
 
virtual string GetFileLocation ()
 Gets the file location (typically a line number) for the current instance. More...
 
virtual string GetEndTagFileLocation ()
 Gets the file location (typically a line number) for the end tag matched with the current instance. More...
 
virtual string GetOriginalContextEndTagLocation ()
 Gets the file location (typically a line number) for the end tag of an 'original context'. More...
 
virtual ISourceInfo GetOriginalContextSourceInfo ()
 Gets information about the source of the current element. More...
 
virtual string GetFullFilePathAndLocation ()
 Gets the full file path and location for the current element. More...
 
virtual void CacheSourceInformationInAttributes ()
 Writes information to the underlying element's attributes recording its source information. More...
 
virtual void MarkAsImported (IZptElement originalElement)
 Marks the current element as being imported into its parent document (IE: it represents a context switch). More...
 
 ZptElement (ISourceInfo sourceFile, bool isRoot, bool isImported, IZptDocument ownerDocument, ISourceInfoFactory sourceInfoCreator=null)
 Initializes a new instance of the CSF.Zpt.Rendering.ZptElement class. More...
 

Protected Member Functions

override string GetNativeFileLocation ()
 Gets the file location (typically a line number) for the current instance. More...
 
virtual int GetLineNumber ()
 Gets the current instance's line number. More...
 
override string GetNativeEndTagFileLocation ()
 Gets the file location (typically a line number) for the end tag matched with the current instance. More...
 
- Protected Member Functions inherited from CSF.Zpt.Rendering.ZptElement
virtual TElement ConvertTo< TElement > (IZptElement element)
 Converts the given IZptElement to an implementation-specific subclass, or raises an exception if the conversion is not valid. More...
 
virtual void EnforceParentNodeNotNull (object parentNode)
 Enforces that an System.Object (representing a parent node) is not null, raising an exception if it is not. More...
 
virtual void EnforceNodeType< TNodeType > (string expectedNodeLanguage, TNodeType expectedNodeType, TNodeType actualNodeType)
 Enforces that two objects (expected and actual), representing node types, are equal. Raises an exception if they are not. More...
 
 ZptElement ()
 Fake constructor for Mocking framework usage only. Do not call. More...
 

Properties

virtual XElement Node [get]
 Gets the XML node object wrapped by the current instance. More...
 
override string Name [get]
 Gets the element name. More...
 
override bool HasParent [get]
 Gets a value indicating whether this instance has a parent element or not. More...
 
override Type ZptDocumentType [get]
 Gets a System.Type indicating the type of IZptDocument to which the current instance belongs. More...
 
override bool CanWriteCommentWithoutParent [get]
 Gets a value indicating whether or not this instance can write a comment node to a node that does not have a parent. More...
 
- Properties inherited from CSF.Zpt.Rendering.ZptElement
abstract string Name [get]
 Gets the element name. More...
 
virtual bool IsRoot [get]
 Gets a value indicating whether this instance is the root of its parent document. More...
 
abstract bool HasParent [get]
 Gets a value indicating whether this instance has a parent element or not. More...
 
virtual bool IsImported [get]
 Gets a value indicating whether this instance represents an element imported from another document tree. More...
 
abstract Type ZptDocumentType [get]
 Gets a System.Type indicating the type of IZptDocument to which the current instance belongs. More...
 
abstract bool CanWriteCommentWithoutParent [get]
 Gets a value indicating whether or not this instance can write a comment node to a node that does not have a parent. More...
 
virtual IZptDocument OwnerDocument [get]
 Gets the IZptDocument instance to which the current instance belongs. More...
 
- Properties inherited from CSF.Zpt.Rendering.IZptElement
string Name [get]
 Gets the element name. More...
 
bool IsRoot [get]
 Gets a value indicating whether this instance is the root of its parent document. More...
 
bool HasParent [get]
 Gets a value indicating whether this instance has a parent element or not. More...
 
bool IsImported [get]
 Gets a value indicating whether this instance represents an element imported from another document tree. More...
 
Type ZptDocumentType [get]
 Gets a System.Type indicating the type of IZptDocument to which the current instance belongs. More...
 
bool CanWriteCommentWithoutParent [get]
 Gets a value indicating whether or not this instance can write a comment node to a node that does not have a parent. More...
 
IZptDocument OwnerDocument [get]
 Gets the IZptDocument instance to which the current instance belongs. More...
 

Additional Inherited Members

- Static Protected Member Functions inherited from CSF.Zpt.Rendering.ZptElement
static void EnforceNameNotEmpty (string name)
 Enforces that a name must not be null or empty, raising an exception if it is. More...
 

Detailed Description

Implementation of ZptElement based on documents parsed using System.Xml.Linq.

Constructor & Destructor Documentation

CSF.Zpt.DocumentProviders.ZptXmlLinqElement.ZptXmlLinqElement ( XNode  node,
ISourceInfo  sourceFile,
IZptDocument  ownerDocument,
bool  isRoot = false,
bool  isImported = false 
)
inline

Initializes a new instance of the CSF.Zpt.DocumentProviders.ZptXmlLinqElement class.

Parameters
nodeThe source XML Node.
sourceFileInformation about the element's source file.
isRootWhether or not this is the root element.
isImportedWhether or not this element is imported.
ownerDocumentThe ZPT document which owns the element.

Member Function Documentation

override void CSF.Zpt.DocumentProviders.ZptXmlLinqElement.AddCommentAfter ( string  comment)
inlinevirtual

Adds a new comment to the DOM immediately after the current element.

Parameters
commentThe comment text.

Implements CSF.Zpt.Rendering.ZptElement.

override void CSF.Zpt.DocumentProviders.ZptXmlLinqElement.AddCommentBefore ( string  comment)
inlinevirtual

Adds a new comment to the DOM immediately before the current element.

Parameters
commentThe comment text.

Implements CSF.Zpt.Rendering.ZptElement.

override void CSF.Zpt.DocumentProviders.ZptXmlLinqElement.AddCommentInside ( string  comment)
inlinevirtual

Adds a new comment to the DOM inside the current element as its first child.

Parameters
commentThe comment text.

Implements CSF.Zpt.Rendering.ZptElement.

override IZptElement CSF.Zpt.DocumentProviders.ZptXmlLinqElement.Clone ( )
inlinevirtual

Clone this instance into a new Element instance, which may be manipulated without affecting the original.

Implements CSF.Zpt.Rendering.ZptElement.

override IZptDocument CSF.Zpt.DocumentProviders.ZptXmlLinqElement.CreateDocumentFromThisElement ( )
inlinevirtual

Creates a new IZptDocument which contains only the current element and its children.

Returns
A new document instance.

Implements CSF.Zpt.Rendering.ZptElement.

override bool CSF.Zpt.DocumentProviders.ZptXmlLinqElement.Equals ( ZptElement  other)
inlinevirtual

Determines whether the specified CSF.Zpt.Rendering.ZptElement is equal to the current CSF.Zpt.DocumentProviders.ZptXmlLinqElement.

Parameters
otherThe CSF.Zpt.Rendering.ZptElement to compare with the current CSF.Zpt.DocumentProviders.ZptXmlLinqElement.
Returns
true if the specified CSF.Zpt.Rendering.ZptElement is equal to the current CSF.Zpt.DocumentProviders.ZptXmlLinqElement; otherwise, false.

Implements CSF.Zpt.Rendering.ZptElement.

override IZptAttribute CSF.Zpt.DocumentProviders.ZptXmlLinqElement.GetAttribute ( ZptNamespace  attributeNamespace,
string  name 
)
inlinevirtual

Gets an attribute which matches the given criteria, or a null reference is no matching attribute is found.

Returns
The attribute, or a null reference.
Parameters
attributeNamespaceThe attribute namespace.
nameThe attribute name.

Implements CSF.Zpt.Rendering.ZptElement.

override IZptAttribute [] CSF.Zpt.DocumentProviders.ZptXmlLinqElement.GetAttributes ( )
inlinevirtual

Gets a collection of the attributes present upon the current element.

Returns
The attributes.

Implements CSF.Zpt.Rendering.ZptElement.

override IZptElement [] CSF.Zpt.DocumentProviders.ZptXmlLinqElement.GetChildElements ( )
inlinevirtual

Gets a collection of the child elements from the current source element.

Returns
The children.

Implements CSF.Zpt.Rendering.ZptElement.

override int CSF.Zpt.DocumentProviders.ZptXmlLinqElement.GetHashCode ( )
inlinevirtual

Serves as a hash function for a CSF.Zpt.DocumentProviders.ZptXmlLinqElement object.

Returns
A hash code for this instance that is suitable for use in hashing algorithms and data structures such as a hash table.

Implements CSF.Zpt.Rendering.ZptElement.

virtual int CSF.Zpt.DocumentProviders.ZptXmlLinqElement.GetLineNumber ( )
inlineprotectedvirtual

Gets the current instance's line number.

Returns
The line number.
override string CSF.Zpt.DocumentProviders.ZptXmlLinqElement.GetNativeEndTagFileLocation ( )
inlineprotectedvirtual

Gets the file location (typically a line number) for the end tag matched with the current instance.

Returns
The end tag file location.

Implements CSF.Zpt.Rendering.ZptElement.

override string CSF.Zpt.DocumentProviders.ZptXmlLinqElement.GetNativeFileLocation ( )
inlineprotectedvirtual

Gets the file location (typically a line number) for the current instance.

Returns
The file location.

Implements CSF.Zpt.Rendering.ZptElement.

override IZptElement CSF.Zpt.DocumentProviders.ZptXmlLinqElement.GetParentElement ( )
inlinevirtual

Gets the element which is the parent of the current instance.

Returns
The parent element.

Implements CSF.Zpt.Rendering.ZptElement.

override IZptElement CSF.Zpt.DocumentProviders.ZptXmlLinqElement.InsertAfter ( IZptElement  existing,
IZptElement  newChild 
)
inlinevirtual

Inserts a new child element into the current element's child elements. The new child will be the next sibling after a given existing child.

Returns
The newly-added element.
Parameters
existingAn existing child element, after which the child will be inserted.
newChildThe new child element to insert.

Implements CSF.Zpt.Rendering.ZptElement.

override IZptElement CSF.Zpt.DocumentProviders.ZptXmlLinqElement.InsertBefore ( IZptElement  existing,
IZptElement  newChild 
)
inlinevirtual

Inserts a new child element into the current element's child elements. The new child will be the previous sibling before a given existing child.

Returns
The newly-added element.
Parameters
existingAn existing child element, before which the child will be inserted.
newChildThe new child element to insert.

Implements CSF.Zpt.Rendering.ZptElement.

override bool CSF.Zpt.DocumentProviders.ZptXmlLinqElement.IsFromSameDocumentAs ( IZptElement  other)
inlinevirtual

Determines whether this instance is from same document as the specified element.

Returns
true if this instance is from same document as the specified element; otherwise, false.
Parameters
otherThe element to test.

Implements CSF.Zpt.Rendering.ZptElement.

override bool CSF.Zpt.DocumentProviders.ZptXmlLinqElement.IsInNamespace ( ZptNamespace  nSpace)
inlinevirtual

Determines whether or not the current instance is in the specified namespace.

Returns
true if this instance is in the specified namespace; otherwise, false.
Parameters
nSpaceThe namespace for which to test.

Implements CSF.Zpt.Rendering.ZptElement.

override IZptElement [] CSF.Zpt.DocumentProviders.ZptXmlLinqElement.Omit ( )
inlinevirtual

Omits the current element, replacing it with its children.

Returns
A collection of the IZptElement instances which were children of the element traversed

Implements CSF.Zpt.Rendering.ZptElement.

override void CSF.Zpt.DocumentProviders.ZptXmlLinqElement.PurgeAttributes ( ZptNamespace  attributeNamespace)
inlinevirtual

Recursively searches for attributes with a given namespace or prefix and removes them from their parent element.

Parameters
attributeNamespaceThe attribute namespace.

Implements CSF.Zpt.Rendering.ZptElement.

override void CSF.Zpt.DocumentProviders.ZptXmlLinqElement.PurgeElements ( ZptNamespace  elementNamespace)
inlinevirtual

Recursively searches for elements with a given namespace or prefix and removes them using the Omit behaviour.

Parameters
elementNamespaceThe element namespace.

Implements CSF.Zpt.Rendering.ZptElement.

override void CSF.Zpt.DocumentProviders.ZptXmlLinqElement.Remove ( )
inlinevirtual

Removes the current element from the DOM.

Implements CSF.Zpt.Rendering.ZptElement.

override void CSF.Zpt.DocumentProviders.ZptXmlLinqElement.RemoveAllChildren ( )
inlinevirtual

Removes all child elements from the current element.

Implements CSF.Zpt.Rendering.ZptElement.

override void CSF.Zpt.DocumentProviders.ZptXmlLinqElement.RemoveAttribute ( ZptNamespace  attributeNamespace,
string  name 
)
inlinevirtual

Removes a named attribute.

Parameters
attributeNamespaceThe attribute namespace.
nameThe attribute name.

Implements CSF.Zpt.Rendering.ZptElement.

override void CSF.Zpt.DocumentProviders.ZptXmlLinqElement.ReplaceChildrenWith ( string  content,
bool  interpretContentAsStructure 
)
inlinevirtual

Removes all children of the current element instance and replaces them with the given content.

Parameters
contentThe content with which to replace the children of the current element.
interpretContentAsStructureIf set to true then the content is interpreted as structure.

Implements CSF.Zpt.Rendering.ZptElement.

override IZptElement CSF.Zpt.DocumentProviders.ZptXmlLinqElement.ReplaceWith ( IZptElement  replacement)
inlinevirtual

Replaces the current element in its respective DOM with the given replacement.

Returns
A reference to the replacement element, in its new DOM.
Parameters
replacementReplacement.

Implements CSF.Zpt.Rendering.ZptElement.

override IZptElement [] CSF.Zpt.DocumentProviders.ZptXmlLinqElement.ReplaceWith ( string  content,
bool  interpretContentAsStructure 
)
inlinevirtual

Replaces the current element instance with the given content.

Returns
A collection of IZptElement, indicating the element(s) which replaced the current instance.
Parameters
contentThe content with which to replace the current element.
interpretContentAsStructureIf set to true then the content is interpreted as structure.

Implements CSF.Zpt.Rendering.ZptElement.

override IZptElement [] CSF.Zpt.DocumentProviders.ZptXmlLinqElement.SearchChildrenByAttribute ( ZptNamespace  attributeNamespace,
string  name 
)
inlinevirtual

Recursively searches the children of the current instance, returning a collection of elements which have an attribute matching the given criteria.

Returns
The matching child elements.
Parameters
attributeNamespaceThe attribute namespace.
nameThe attribute name.

Implements CSF.Zpt.Rendering.ZptElement.

override void CSF.Zpt.DocumentProviders.ZptXmlLinqElement.SetAttribute ( ZptNamespace  attributeNamespace,
string  name,
string  value 
)
inlinevirtual

Sets the value of an attribute.

Parameters
attributeNamespaceThe attribute namespace.
nameThe attribute name.
valueThe attribute value.

Implements CSF.Zpt.Rendering.ZptElement.

override string CSF.Zpt.DocumentProviders.ZptXmlLinqElement.ToString ( )
inlinevirtual

Returns a System.String that represents the current ZptXmlLinqElement.

Returns
A System.String that represents the current ZptXmlLinqElement.

Implements CSF.Zpt.Rendering.ZptElement.

Property Documentation

override bool CSF.Zpt.DocumentProviders.ZptXmlLinqElement.CanWriteCommentWithoutParent
get

Gets a value indicating whether or not this instance can write a comment node to a node that does not have a parent.

true if this instance can write a comment node if it does not have a parent; otherwise, false.

override bool CSF.Zpt.DocumentProviders.ZptXmlLinqElement.HasParent
get

Gets a value indicating whether this instance has a parent element or not.

true if this instance has a parent element; otherwise, false.

override string CSF.Zpt.DocumentProviders.ZptXmlLinqElement.Name
get

Gets the element name.

The name.

virtual XElement CSF.Zpt.DocumentProviders.ZptXmlLinqElement.Node
get

Gets the XML node object wrapped by the current instance.

The node.

override Type CSF.Zpt.DocumentProviders.ZptXmlLinqElement.ZptDocumentType
get

Gets a System.Type indicating the type of IZptDocument to which the current instance belongs.

The type of ZPT document implementation.


The documentation for this class was generated from the following file: