October 31, 2007
xhtml, xml, xslt
No Comments
Managed to complete one of my project for this semester.
Page are generated from xslt process and rendered to xhtml format. Page navigations are controlled using xAjax component.
Try it out and have fun 
http://www.lindaocta.com/linda/stuff/xmlAssignment/index.php
October 9, 2007
xml
No Comments
One of my master project is using xml to create a website. As I understand using xsd:key and xsd:keyref are easy if the primary key and foreign key are existed in the same xml file. What I am trying to do below are separating the document into two xml file and for the schema, the foreign key of one schema will point to primary key of another schema, but my schema validation is not giving me a right result
.
Below are the summarize of my xml file:
primary.xsd
<xsd:key name=”uniqueUserId”>
<xsd:selector xpath=”.//user/userId”/>
<xsd:field xpath=”.”/>
</xsd:key>
with primary.xml
<userList>
<user><userId>1</userId></user>
<user><userId>2</userId></user>
</userList>
When I validate the above primary.xml against primary.xsd (using xmllint), my data is valid. Note: that above xsd:key also check for duplicate.
foreign.xsd
<xsd:include schemaLocation=”user.xsd” />
<xsd:keyref name=”refUserId” refer=”uniqueUserId”>
<xsd:selector xpath=”idea/userId”/>
<xsd:field xpath=”.”/>
</xsd:keyref>
foreign.xml
<ideaList>
<idea><ideaId>1</ideaId><userId>1</userId></idea>
<idea><ideaId>2</ideaId><userId>2</userId></idea>
<idea><ideaId>3</ideaId><userId>3</userId></idea>
</ideaList>
When I validate foreign.xml against foreign.xsd using xmllint –schema foreign.xsd foreign.xml, i get below error (the correct answer should be only for ideaId=3 since userId 3 is not exist):
foreign.xml:12: Schemas validity error : Element ‘userId’: No match found for key-sequence ['1'] of keyref ‘refUserId’.
foreign.xml:18: Schemas validity error : Element ‘userId’: No match found for key-sequence ['2'] of keyref ‘refUserId’.
foreign.xml:24: Schemas validity error : Element ‘userId’: No match found for key-sequence ['3'] of keyref ‘refUserId’.
I am trying to sort the problem till now. Any help will be appreciated