how to write xml schema(XSD) - xsd

I want to write one XML schema(XSD)
in which
element have multiple occurences and have one attribute ID
I want validate if borrower's ID attribute have a value equal to 1 then all its subelement must have some value.
is this possible with XSD?
Please suggest me if their is a way to achieve this
thanks

Conditional's like you are requesting are not possible in XML schema's. You might want to look at RELAX NG(http://relaxng.org/).

Related

Difference between XSD Simple element and XSD Complex element

I Googled this Question but still i'm unable to find the best difference for the Simple XSD (XML Schema Definition) Element and Complex XSD Element.
Any guidance would be highly appreciated.
I have no idea, why I answer this. But...
To summarize,
simple types can only have content directly contained between the element’s opening and closing tags. They cannot have attributes or child elements.
complex types can have attributes, can contain other elements, can contain a mixture of elements and text, etc etc.
One is a single value and the other a compound value.

Ignore ID in Attribute Selection

I have a dataset with an unique id for each instance. Now I am running some Attribute Selection on that dataset. Concrete I use the CfsSubsetEval for selecting the relevant attributes.
The problem is that I don't want to include the id in this attribute selection, but I need it later to write out a .arff File (which should contain the id and the selected attributes).
I found some posts which used the FilteredClassifier. But in my case I want to have something like a FilteredAttributeSelection. Something like an exklusive view on the data for the AttributeSelection Algorithm.
Is there a way solving this problem?
Thanks in advance!
I solved the problem by copying the attribute vector (the ids) before the filter. After selecting the attributes I restore it.

how to write xml schema(XSD)

I want to right one XML schema(XSD)
in which
element have multiple occurences and have one attribute ID
I want validate if borrower's ID attribute have a value equal to 1 then all its subelement must have some value.
is this possible with XSD?
Please suggest me if their is a way to achieve this
thanks
Not possible as far as I can remember, but it is totally OK to first validate the XML using XSD and then have some additional, application-specific validation logic on top of that.

Given an XSD is it possible to list a hierarchy of elements and their attributes?

Lets pretend I have an XSD document and I want to produce a list of all elements along with their attributes and the children of the elements. I could also approach this by asking if you are to implement code completion based on an xsd document, and you want to list the children of the element and an elements attributes, how would you approach this problem?
Since XSD is valid XML document it just a matter of selecting XML parsing library of your choice. For example XLinq (.NET FW 3+) will do the job.
You can just walk through complexType, sequence and other elements to find out a list of possible values.

XML Schema (XSD) - if one element has specific value then another element must be present and vice versa

Can I express this in an XSD?
For example:
One element is a required bool element named EmployedMoreThanThirteenWeeks and if the value is set to false I want the schema to require the existence of another element named EmploymentDate. And the other way around if the value is true then ideally the EmploymentDate element should be denied but I can accept it being optional.
No. An XSD just defines structure and data types, not relations. It is possible to add a key reference between elements but that won't prevent invalid nodes, just invalid values.
You can create an XSLT file (an XML Stylesheet) which will validate the XML file for you and thus generate a report of errors.
I think that XSD CANT do that, because the schemas verifies just an STRUCTURE (tree), and not VALUES (though you can check the value format).
You should consider other validation ways.

Resources