???????? ? ObjectXPathNavigator - PowerPoint PPT Presentation

1 / 15
About This Presentation
Title:

???????? ? ObjectXPathNavigator

Description:

???????? ??? ?????? ???????? ? ??????: ??????????? ?? ??????; ????? ?????? ? ... ????????, ?????????????? ?????????? ? ?????????? ??????? ???-???????? (POJO) ... – PowerPoint PPT presentation

Number of Views:58
Avg rating:3.0/5.0
Slides: 16
Provided by: XOR
Category:

less

Transcript and Presenter's Notes

Title: ???????? ? ObjectXPathNavigator


1
???????? ? ObjectXPathNavigator
  • ??????????
  • ???????
  • ???????????

2
??????????
  • ???????? ??? ?????? ???????? ? ??????
  • ??????????? ?? ?????? ????? ?????? ? ????????
    ?????.
  • ????????????? ??????????? ?????? XML-?????.
  • ??????? ?????? ???????? ????? XPath.
  • ????????????? ????? ???????? ???
    XSLT-?????????????.

3
???????
  • XPath Querying Over Objects with
    ObjectXPathNavigator
  • ?????? ? MSDN March 2003. Steve Saxon, Dell
    Computer Corporation.
  • JXPath
  • ??????? ????????????? XPath ????? ???? ????????
    ? ??????? ?????? ????????.
  • ????????? ????????? XPath-??????? ? ????????
    ?????????.
  • ????????????, ????????, ????????? ? Prevayler.
  • Prevayler
  • ??????? ?? ????????? ????????, ??????????????
    ?????????? ? ?????????? ??????? ???-????????
    (POJO).
  • ???? ??????????? - ?????? 2.3 (????) ???????? 7
    ???? 2006.
  • Bamboo.Prevalence
  • ?????? Prevayler ??? .NET.
  • ???????? XPathObjectNavigator (?????? JXPath).

4
?????????? ?????? ??????? ??? .NET
  • ????????????? ????????? ?????? XML
  • ?? ??????????? ???????
  • XmlSerializer
  • ? ???????? ????????? ????????? ??????.
  • ?? XmlSerializer ??????? ??????????? ??? ? XML, ?
    ?????? ????? ?????? ??? ??????????.

5
?????????????
?????????? ?????????????
ObjectXPathContext context new
ObjectXPathContext() XPathNavigator nav
context.CreateNavigator( o )
??????????? ???????????? ????
ObjectXPathContext context new
ObjectXPathContext( nsmgr ) context.NamespaceMana
ger.AddNamespace( "sdf", Namespaces.SDF
) XPathNavigator nav context.CreateNavigator(
o )
6
?????????????
??????????? ??????????? ???????? ? ??????????
ObjectXPathContext context new
ObjectXPathContext( nsmgr ) context.RegisterNode
Policy( typeof( INullableType ), typeof(
NullableNodePolicy ) ) context.ConverterFactory.
AddConverter( typeof( NullableDateTime ), new
NullableDateTimeConverter() ) XPathNavigator
nav context.CreateNavigator( o )
7
???????? ????????
??? ???????? ?????? ??????????
???????? XML ????
XmlRoot( "product", NamespaceNamespaces.SDF
) public class Product XmlAttribute( "id"
) public int ProductId get ... set ...
XmlAttribute( "name" ) public string
Field1 get ... set ... XmlElement(
"description" ) public string Description get
... set ... XmlElement( "Date",
FormXmlSchemaForm.Unqualified ) Converter(
typeof( SimpleConverter )) public DateTime
Date get ... set ... XmlAnyElement
public XmlElement Xml get ... set ...
ltsdfproduct id"123" name"Red button"
xmlnssdf"..."gt ltsdfdescriptiongt Red
button description lt/sdfdescriptiongt ltDategt10.
10.2006lt/Dategt ... lt/sdfproductgt
8
???????????
  • ObjectXPathNavigator ??????????? ?????
  • ????????? ? ?????? XPathNavigator.
  • ???????????? ???????? ?? ?????? ????? (?????????,
    ?????????).
  • ?????? ??????????? ????????? ?? ???? ?????? ??
    ????????.
  • ????????? ????????? ??????????.
  • ???? ?????? ???????? ? ???? ??????????? ??????
    Node.
  • Node
  • ?????????? ?????? XmlNode.
  • ????????? ????????? ??????? ??? ????? ?????
    ?????????.
  • ????????? ????????? ???????? ????????, ????? ???
    ??????? ?????????.

9
???????????
  • NodePolicy ????????
  • ???????? ???????? ?? ????????? ???? ????????.
  • ????????????? ???????? Policy (Strategy).
  • ???????? ??????????.
  • ????????? ?????? ????????? ????? ?? ????.
  • ????????? ??????????? ????????
  • GenericNodePolicy. ??????????? ???????? ????????
    ??????? ? ???????? ? ????????.
  • MemberNodePolicy ??????????? ????, ????????
    ??????? ??? ?? ?????????? ???????????.
  • TextNodePolicy ??????????? ???? ???? ???????,
    ??????????? ? ????? ? ???????? ??????????.
  • ListNodePolicy ????????? ???????????? ??
    ??????????? ????????, ??????????? ?????????
    IList.

10
???????????
  • ??????????
  • ? XML-?????? ????????? ????? ????? ???????
    ?????????????? ? ???? ???????? ??????.
  • ?????????? ??????????? ???????? ????? ? ?????.
  • ????? ?????? ????? ?????????? ? ?????????????? ??
  • ????????? ??????????? ??????????
  • GenericConverter ?????? ?????????? ToString().
  • BooleanConverter, DateTimeConverter,
    DoubleConverter ? ?.?. ??????????? ????????? ?
    ??? ??????, ??????? ?????? ??? XML.
  • EnumConverter ??????????? ???????? ? ????????,
    ??? ??? ?????? ? ????.

11
?????????? ????
????????, ??? ??????
  • ?????????? ???? ?????? ?????????? ?????? XML.
  • ????????? ?? ??????????????? ?? ?????????? ????
  • ??????? ???? ??????????
  • ??????? Transparent(true).
  • ????? GetIsTransparent.
  • ????????? ???? ???????? ??????????? ???
    ???????????? ???????? ?????? XmlSerializer.

public class Person string Name string
Alias
??????? XML
ltPersongt ltNamegtJohn Smithlt/Namegt ltAliasgt
ltstringgtJohnnylt/stringgt ltstringgtSmithylt/stri
nggt lt/Aliasgt lt/Persongt
? ???????? ?? ????????
ltpersongt ltnamegtJohn Smithlt/namegt
ltaliasgtJohnnylt/aliasgt ltaliasgtSmithylt/aliasgt
lt/persongt
12
?????????? ????? ???????
INodePolicy
  • ???????? ????????? ????????? INodePolicy
  • ?????? ????????????.
  • GetNewPolicy ?????????? ??? ????????? ????????
    ???????.
  • GetPolicy - ????? ??? ????????? ??????????
    ????????.
  • ??????????? ????????
  • ??????? NodePolicy ?? ???????? ??? ??????.
  • ????? RegisterNodePolicy (??? ???????, ???
    ????????).
  • ??? ??????? ????? ???? ???????????.
  • ??????? NodePolicyGet.

public interface INodePolicy INodePolicy
GetNewPolicy( Node node ) string GetName( Node
node ) string GetNamespace( Node node
) XPathNodeType GetNodeType( Node node
) string GetValue( Node node ) bool
GetIsTransparent( Node node ) int
GetAttributesCount( Node node ) Node
GetAttribute( Node node, int index ) int
FindAttribute( Node node, string name, string ns
) int GetChildrenCount( Node node ) Node
GetChild( Node node, int index )
public static new INodePolicy GetPolicy() ...
13
?????????? ????? ???????????
IConverter
  • ????????? ????????? ????????? IConverter
  • ToString - ??????????? ???????? ??????? ? ?????.
  • ParseString ? ?????? ?????? ?? ????????????.
  • ??????????? ??????????
  • ??????? Converter ?? ???????? ??? ??????.
  • ????????? ????? AddConverter.

public interface IConverter string ToString(
object obj ) object ParseString( string str )
14
????????? ?????????
  • ?????? ????????????? ?? ???????????
    ??????????????.
  • ??????????? ?????? ??????.
  • ?????????? ?????? ????? ?????????.
  • ?????????? ?????.
  • ?????????????? ????????????.
  • ? ?.?.

15
??????????
  • ???????? MIT-style.
  • ??????? ?????? ?? ????? ?????http//blogs.byte-f
    orce.com/files/12/objectxpathnavigator/default.asp
    x
  • ????? ?? ???????? http//blogs.byte-force.com/fo
    rums/28/ShowForum.aspx
Write a Comment
User Comments (0)
About PowerShow.com