468,315 Members | 1,403 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,315 developers. It's quick & easy.

XSd problem,...

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!

Jun 6 '06 #1
4 1057
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

Jun 6 '06 #2
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


Jun 6 '06 #3
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


Jun 9 '06 #4
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


Jun 9 '06 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

11 posts views Thread by Kostatus | last post: by
117 posts views Thread by Peter Olcott | last post: by
18 posts views Thread by Ian Stanley | last post: by
28 posts views Thread by Jon Davis | last post: by
6 posts views Thread by Ammar | last post: by
2 posts views Thread by Mike Collins | last post: by
reply views Thread by Teichintx | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.