Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > XSd problem,...

Reply
Thread Tools

XSd problem,...

 
 
mavis
Guest
Posts: n/a
 
      06-06-2006
If I want to assign different value to different versions as the
followings:

<versions>
<version>
<name> a20 </name>
<value> 10 </value>
</version>

<version>
<name> b40 </name>
<value> 50 </value>
</version>

<version>
<name> others</name>
<value> 5 </value>
</version>
</versions>

I guess it cannot be simplified as below, even if we can use <xs:choice
maxOccurs="unbounded"> to define elements in any order with any
occurrences.. the problem is we cannot identify corresponding value for
each version...

<versions>
<version> a20 </version>
<value> 10 </value>

<version> b40 </version>
<value> 50 <value>

<version> others </version>
<value> 5 </value>
</versions>

Am I right? Could anyone confirm me about this if possible?
Thanks a lot!

 
Reply With Quote
 
 
 
 
George Bina
Guest
Posts: n/a
 
      06-06-2006
Hi,

You can define a sequence in the schema and specify the name and value
inside that sequence, then set the occurances on the sequence to handle
more versions, like below for instance:

<xs:element name="versions">
<xs:complexType>
<xs:sequence maxOccurs="unbounded">
<xs:element name="version"/>
<xs:element name="value"/>
</xs:sequence>
</xs:complexType>
</xs:element>

Getting the value for a version element should be easy, in XSLT for
instance if you match on a version element the the value is given by
the following XPath expression (assuming the document is valid against
the schema)

following-sibling::*[1]

Best Regards,
George
---------------------------------------------------------------------
George Cristian Bina
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com

 
Reply With Quote
 
 
 
 
mavis
Guest
Posts: n/a
 
      06-06-2006
Thanks a lot!!!
Will I get problem if I need to access different values through XPath?
/versions/version/ ? /versions/value?
how can I get corresponding value for each version?
Mavis

George Bina wrote:
> Hi,
>
> You can define a sequence in the schema and specify the name and value
> inside that sequence, then set the occurances on the sequence to handle
> more versions, like below for instance:
>
> <xs:element name="versions">
> <xs:complexType>
> <xs:sequence maxOccurs="unbounded">
> <xs:element name="version"/>
> <xs:element name="value"/>
> </xs:sequence>
> </xs:complexType>
> </xs:element>
>
> Getting the value for a version element should be easy, in XSLT for
> instance if you match on a version element the the value is given by
> the following XPath expression (assuming the document is valid against
> the schema)
>
> following-sibling::*[1]
>
> Best Regards,
> George
> ---------------------------------------------------------------------
> George Cristian Bina
> <oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
> http://www.oxygenxml.com


 
Reply With Quote
 
George Bina
Guest
Posts: n/a
 
      06-09-2006
Hi Mavis,

If you reach a version element then the corresponding value is
following-sibling::*[1].

Best Regards,
George
---------------------------------------------------------------------
George Cristian Bina
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com

mavis wrote:
> Thanks a lot!!!
> Will I get problem if I need to access different values through XPath?
> /versions/version/ ? /versions/value?
> how can I get corresponding value for each version?
> Mavis
>
> George Bina wrote:
> > Hi,
> >
> > You can define a sequence in the schema and specify the name and value
> > inside that sequence, then set the occurances on the sequence to handle
> > more versions, like below for instance:
> >
> > <xs:element name="versions">
> > <xs:complexType>
> > <xs:sequence maxOccurs="unbounded">
> > <xs:element name="version"/>
> > <xs:element name="value"/>
> > </xs:sequence>
> > </xs:complexType>
> > </xs:element>
> >
> > Getting the value for a version element should be easy, in XSLT for
> > instance if you match on a version element the the value is given by
> > the following XPath expression (assuming the document is valid against
> > the schema)
> >
> > following-sibling::*[1]
> >
> > Best Regards,
> > George
> > ---------------------------------------------------------------------
> > George Cristian Bina
> > <oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
> > http://www.oxygenxml.com


 
Reply With Quote
 
mavis
Guest
Posts: n/a
 
      06-09-2006
Thanks a lot. George.

George Bina wrote:
> Hi Mavis,
>
> If you reach a version element then the corresponding value is
> following-sibling::*[1].
>
> Best Regards,
> George
> ---------------------------------------------------------------------
> George Cristian Bina
> <oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
> http://www.oxygenxml.com
>
> mavis wrote:
> > Thanks a lot!!!
> > Will I get problem if I need to access different values through XPath?
> > /versions/version/ ? /versions/value?
> > how can I get corresponding value for each version?
> > Mavis
> >
> > George Bina wrote:
> > > Hi,
> > >
> > > You can define a sequence in the schema and specify the name and value
> > > inside that sequence, then set the occurances on the sequence to handle
> > > more versions, like below for instance:
> > >
> > > <xs:element name="versions">
> > > <xs:complexType>
> > > <xs:sequence maxOccurs="unbounded">
> > > <xs:element name="version"/>
> > > <xs:element name="value"/>
> > > </xs:sequence>
> > > </xs:complexType>
> > > </xs:element>
> > >
> > > Getting the value for a version element should be easy, in XSLT for
> > > instance if you match on a version element the the value is given by
> > > the following XPath expression (assuming the document is valid against
> > > the schema)
> > >
> > > following-sibling::*[1]
> > >
> > > Best Regards,
> > > George
> > > ---------------------------------------------------------------------
> > > George Cristian Bina
> > > <oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
> > > http://www.oxygenxml.com


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
XML + XSD: Is it possible to get all errors against the XSD? Markus Java 1 11-22-2005 02:53 PM
Difference between <import ....xsd> and <xlink:href=.....xsd> ???? Bernd Oninger XML 1 06-30-2004 08:21 AM
xsd:any as a child of xsd:all Peter Aberline XML 0 04-05-2004 03:38 PM
referencing another XSD file within an XSD file JavaDeveloper@nowhere.com XML 1 01-14-2004 05:22 PM
XSD document for XSD defintion Rick Razzano XML 1 09-26-2003 12:41 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57