domingoazul
-
Posts
8 -
Joined
-
Last visited
Content Type
Profiles
Forums
Events
Posts posted by domingoazul
-
-
Hi all,I want to define a schema ('Users') using a element defined on other schema ('Login'). I am using the 'import' element of XML Schema but I am doing something wrong:First part of XSD for Users:
<?xml version="1.0" encoding="ISO-8859-1" ?><xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"xmlns:log="http://www.uib.es/LogIn/"targetNamespace="http://www.uib.es/Users/"xmlns="http://www.uib.es/Users/"elementFormDefault="qualified"><xsd:import namespace="http://www.uib.es/LogIn/" schemaLocation="login-v02.xsd" />
Including the element of the other schema ('Login'):
<xsd:element name="user" type="userType" />...<xsd:complexType name="userType"><xsd:element ref="log:login" />...</xsd:complexType>
And then, in the xml document:
<user xmlns="http://www.uib.es/Users/" xmlns:log="http://www.uib.es/LogIn/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.uib.es/Users/ users-v01.xsd [url="http://www.uib.es/LogIn/"]http://www.uib.es/LogIn/[/url] login-v02.xsd"> <log:login> <log:user>userlogin</log:user> <log:pass>userpass</log:pass> </log:login>...</user>
But the validator says:Element <log:login> is not allowed under element <user> Reason: An element is expected but the relevant choice is unsatisfiableHint: Perhaps one or more choices should not be emptyAny help will be welcome, the hint of the validator is not very helpfull (for me)
-
Ok, thanks!
-
I meant the complexType definitionType what? Is it in the tutorial?
OkAnyhow, I don't think what you're asking is possible in Schema 1.0. The value or existence of one node cannot force the value or existence of another node.
Thanks, it seems to will work. I was searching about something like this 'choose' statement you mention but I can not found anything. Is it part of XML Schema?The closest thing to what you're asking is to have a "choose" statement between two different elements, each enforcing it's own child elements. Those elements could actually refer to other elements, which could be the same. This makes the schema a little more verbose, but it kind'a works for what you want in the end. -
Ups, I have just found the Type Substitutability.My question now is reduced to: can I link the type with the value of the attribute?
-
Hello,I want to associate the content of an element called 'user' depending on the value of its attribute 'profile'.Example:
<user profile="student"> <personalInfo> ... </personalInfo> <contactInfo> ... </contactInfo> <profileInfo> <studies>Biology</studies> </profileInfo></user><user profile="teacher"> <personalInfo> ... </personalInfo> <contactInfo> ... </contactInfo> <profileInfo> <department>Mathematics</department> </profileInfo></user>
'personalInfo' and 'contactInfo' contain same elements, but not 'profileInfo'. I know that one element must have only one definition, so I define the elements on profileInfo with minOccurs="0" and maxOccurs="1". Is it any way to modify the schema and force the 'user' element to use the corresponding elements of 'profileInfo' depending on the value of its attribute 'profile'?Thank youIñaki
use of import
in Schema
Posted
I do not know what I validated but the code works. Sorry for waste your time.