Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

multiple elements on the same row 1

Status
Not open for further replies.

KalmanE

Technical User
May 10, 2010
3
GB
Hello!
I have to produce a schema for this and also style it in XSL and I got stuck. How can I write them if there are more elements on the same row with their attributes? Please help. Thank you!

- <feed>
- <products>
- <loans>
<loan provider="Redmond" activationDate="12/12/08" productName="Redmond Plus Loan" minimumAmount="500" maximumAmount="2500" minimumTerm="6" maximumTerm="36" rate="13.8" />
 
>... if there are more elements on the same row with their attributes?
What does it mean? How about show the forum what you have if there is only a single element on the row with its attributes, whatever it means?
 
Thank you for the reply tsuji. I misunderstood :) It is a single element ont he row with its attributes. Can you please check if my schema is correct and give me some feedback? Pretty please with cherries on top :D

<?xml version="1.0"?>
<xs:schema>

<xs:element name="feed">
<xs:complexType>
<xs:sequence>

<xs:element name="products">
<xs:complexType>
<xs:sequence>

<xs:element name="loans">
<xs:complexType>
<xs:sequence>
<xs:element name="loan"/>
<xs:attribute name="provider" type="xs:string" />
<xs:attribute name="activationDate" type="date" />
<xs:attribute name="productName" type="xs:string" />

<xs:simpleType name="minam">
<xs:restriction base="xs:positiveInteger">
<xs:minInclusive value="500" />
</xs:restriction>
</xs:simpleType>
<xs:attribute name="minimumAmount" type="minam" />

<xs:simpleType name="maxam">
<xs:restriction base="xs:positiveInteger">
<xs:maxInclusive value="2500" />
</xs:restriction>
</xs:simpleType>
<xs:attribute name="maximumAmount" type="maxam"/>

<xs:simpleType name="mint">
<xs:restriction base="xs:positiveInteger">
<xs:minInclusive value="6" />
</xs:restriction>
</xs:simpleType>
<xs:attribute name="minimumTerm" type="mint" />

<xs:simpleType name="maxt">
<xs:restriction base="xs:positiveInteger">
<xs:maxInclusive value="24" />
</xs:restriction>
</xs:simpleType>
<xs:attribute name="maximumTerm" type="maxt"/>

<xs:attribute name="rate" type="xs:decimal"/>

</xs:sequence>
</xs:complexType>
</xs:element>



</xs:sequence>
</xs:complexType>
</xs:element>

</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
 
[0] Those attributes are within loan element. Hence, as shown, xs:element name="loan" is closed before you listing out its attributes is incorrect.

[1] The simpleType element cannot be child of xs:sequence etc... If you want to define simpleType, either you put it directly under the xs:schema as child of it, we may called it (named) global simpleType element or directly under the corresponding xs:attribute without name attribute, making it "local" (anonymous) simpleType.

[2] "date" itself is not defined as any type. It would be unacceptable. w3 schem has some date type but continental dd/mm/yy or mm/dd/yy won't be recognized. You've to define your own.

[2.1] To define rigorously against all oddity that way won't be very straightforward, even awkward. I will show you a simplified version, accepting 31/04, or 20/02... below.

[3] This is how it would appear for a proper schema.
[tt]
<?xml version="1.0"?>
<xs:schema xmlns:xs="[ignore][/ignore]">
<xs:simpleType name="minam">
<xs:restriction base="xs:positiveInteger">
<xs:minInclusive value="500" />
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="maxam">
<xs:restriction base="xs:positiveInteger">
<xs:maxInclusive value="2500" />
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="mint">
<xs:restriction base="xs:positiveInteger">
<xs:minInclusive value="6" />
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="maxt">
<xs:restriction base="xs:positiveInteger">
<xs:maxInclusive value="24" />
</xs:restriction>
</xs:simpleType>
[blue]<xs:simpleType name="date">
<xs:restriction base="xs:positiveInteger">
<xs:pattern value="(0[1-9]|[1-2][0-9]|3[0-1])/(0[1-9]|1[0-2])/(0[1-9]|[1-9][0-9])" />
</xs:simpleType>[/blue]
<xs:element name="feed">
<xs:complexType>
<xs:sequence>
<xs:element name="products">
<xs:complexType>
<xs:sequence>
<xs:element name="loans">
<xs:complexType>
<xs:sequence>
<xs:element name="loan">
<xs:complexType>
<xs:sequence />
<xs:attribute name="provider" type="xs:string" />
<xs:attribute name="activationDate" type="date" />
<xs:attribute name="productName" type="xs:string" />
<xs:attribute name="minimumAmount" type="minam" />
<xs:attribute name="maximumAmount" type="maxam"/>
<xs:attribute name="minimumTerm" type="mint" />
<xs:attribute name="maximumTerm" type="maxt"/>
<xs:attribute name="rate" type="xs:decimal"/>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
[/tt]
[3.1] I edit the lines in the textarea, so watch typo etc... and since there are quite a few subtle changes, it would to laborous to highlight every change. You've to compare it with yours.

[4] You have maxt max set to 24. Your xml have 36. Unless you want to check for validation, you've to change one data or another.
 
Many big thanks Tsuji.
I have learned a lot from you. As the last favour (I almost finished my project) can you please check if my schema is ok?
This is the link where I uploaded it:
and this is the link to the xml file:

Thank you very much again. If I did something wrong (which is very probable) please let me know (if there is a lot to modify - if you want) or modify it yourself (if you want - and please tell me what I did do wrong).

Millions of thanks.
 
Thanks for the feedback.

[3.2] amendments
[3.2.1] Before doing anything else, I have to correct an editing error of simpleType Date. The base type is erroneous due to insufficient editing due to cut-and-paste of a template used in some simpleType above.
[tt]
<xs:simpleType name="date">
<xs:restriction base="xs:[red]string[/red]">
<xs:pattern value="(0[1-9]|[1-2][0-9]|3[0-1])/(0[1-9]|1[0-2])/(0[1-9]|[1-9][0-9])" />
</xs:simpleType>
[/tt]
[3.2.2] The illustration of the meaning of simplified.
>I will show you a simplified version, accepting 31/04, or 20/02... below.
[tt]I will show you a simplified version, accepting 31/04, or [red]3[/red]0/02... below.[/tt]
 
[3.2.1.1] That's killing me! Missing a closing </xs:restriction>
[tt]
<xs:simpleType name="date">
<xs:restriction base="xs:[red]string[/red]">
<xs:pattern value="(0[1-9]|[1-2][0-9]|3[0-1])/(0[1-9]|1[0-2])/(0[1-9]|[1-9][0-9])" />
[red]</xs:restriction>[/red]
</xs:simpleType>
[/tt]
 
[4] I've taken a quick look of the uploads. It looks good and neat. And, I am glad you've made good by your own effort the amendments I mentioned above. That proves, KalmanE, you know your business that makes me doubly happy.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top