Featured post

c# - Usage of Server Side Controls in MVC Frame work -

i using asp.net 4.0 , mvc 2.0 web application. project requiremrnt have use server side control in application not possibl in noraml case. ideally want use adrotator control , datalist control. i saw few samples , references in codepleax mvc controllib howwver found less useful. can tell how utilize theese controls in asp.net application along mvc. note: please provide functionalities related adrotator , datalist controls not equivalent functionalities thanks in advace. mvc pages not use normal .net solution makes use of normal .net components impossible. a normal .net page use event driven solution call different methods service side mvc use actions , view completly different way handle things. also, mvc not use viewstate normal .net controlls require. found article discussing mixing of normal .net , mvc.

xsd - XML Schema key/keyref - how to use them? -


long story short : know how use key/keyref xsd let elements have references each other. has have form of example, using simple xsd , xml.

long story : familiar usage of id/idref. use connect elements jaxb. have been told repeatedly key/keyref construct in xsd offers enhanced flexibility inter-element referencing. have consulted oreilly xml schema book, seems teach correct definition of key/keyref , how similar id/idref (but better) , doesn't give simple example of use. doesn't seem similar, because define id attribute in 1 element , idref in element , voila. key/keyref have defined in common ancestor of referencing , referenced element (afaik)...

i use xsd files generate jaxb-bound java classes xjc

i have searched how-tos, tutorials , examples, google gives me scraps. same searches on (also google , inclusive search '+' ).

in order make everyone's lives easier have prepared xsd defined key/keyref pair have understood it.

<xs:schema elementformdefault="qualified" xmlns:xs="http://www.w3.org/2001/xmlschema"> <xs:element name="root">     <xs:complextype>         <xs:sequence>             <xs:element name="referenced">                 <xs:complextype>                     <xs:attribute name="id" type="xs:string" />                 </xs:complextype>             </xs:element>             <xs:element name="owner">                 <xs:complextype>                     <xs:attribute name="id" type="xs:string" />                 </xs:complextype>             </xs:element>         </xs:sequence>     </xs:complextype>     <xs:key name="akey">         <xs:selector xpath="owner" />         <xs:field xpath="@id" />     </xs:key>     <xs:keyref name="akeyref" refer="akey">         <xs:selector xpath="referenced" />         <xs:field xpath="@id" />     </xs:keyref> </xs:element> 

how piece of xml like, 'owner'-element referencing 'referenced'-element?

edit : applied change proposed tom w, changing xpath attribute of key element "owner". jaxb (xjc) still doesnt care though.

thank you

there no special syntax in instance document. required keyref node matches extant key node. validation tell whether or not key constraint satisfied.

re code:

i've started dabbling keys myself, think i've spotted error in yours - akey should like:

<xs:key name="akey">     <xs:selector xpath="owner" />     <xs:field xpath="@id" /> </xs:key> 

furthermore - gotcha - key constraints don't recognise default namespace. must prefix every part of selector xpath namespace prefix of element you're looking up. if don't have namespace prefix - tough, you'll need add one. limitation of standard.


Comments

Popular posts from this blog

c# - Usage of Server Side Controls in MVC Frame work -

cocoa - Nesting arrays into NSDictionary object (Objective-C) -

ios - Very simple iPhone App crashes on UILabel settext -