|
|
 |
| XML General XML discussions. |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the XML section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of computer programmers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other programmers’ questions, win occasional prizes given to our best members, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
|
|
 |

July 1st, 2009, 12:22 PM
|
|
Registered User
|
|
Join Date: Jun 2009
Posts: 5
Thanks: 1
Thanked 0 Times in 0 Posts
|
|
Parse XML
Hi,
I'd like to parse XML inside XSD. I need to get dynamicly data from XML a build this dynamicly:
<xs:simpleType name="categories">
<xs:restriction base="xs:normalizedString">
<xs:enumeration value="from XML"/>
</xs:restriction>
</xs:simpleType>
Does anyone if I can do that? Otherwise any idea to do it different way...
Thanks in advance
|

July 1st, 2009, 12:28 PM
|
 |
Friend of Wrox
|
|
Join Date: Aug 2007
Location: Newcastle, , United Kingdom.
Posts: 1,453
Thanks: 0
Thanked 50 Times in 50 Posts
|
|
Please try to write a better question. We've no idea what you want - where is your XML, what does it look like, what are you using to 'process' the XSD?
Try looking at this post for help on how to write a good post: Hints for a good XSLT post
__________________
/- Sam Judson : Wrox Technical Editor -/
|

July 1st, 2009, 12:46 PM
|
|
Registered User
|
|
Join Date: Jun 2009
Posts: 5
Thanks: 1
Thanked 0 Times in 0 Posts
|
|
Ok, I'm working with Alfresco. I have one field which is categories in a web form. The web form get the structure from XSD, so I'd like to get the values of that field dynamicly. Thus, I thought I could use parse a XML inside the XSD, this way I can get the values dynamicly. The type of categories would be SimpleType.
This my categories right now:
<xs:simpleType name="categories">
<xs:restriction base="xs:normalizedString">
<xs:enumeration value="Commnications"/>
<xs:enumeration value="Collaboration"/>
<xs:enumeration value="Academic"/>
<xs:enumeration value="Community"/>
<xs:enumeration value="Student Informations Systems"/>
<xs:enumeration value="Administrative Systems"/>
<xs:enumeration value="Career"/>
</xs:restriction>
</xs:simpleType>
I'd like to parse all the values from external file, so I don't know if I can do it. I've looked for soluctions in Internet, but I haven't found anything.
Can someone help me out with any way to solve this problem?
Thanks
PD: I'm sorry for last post
|

July 1st, 2009, 12:52 PM
|
 |
Wrox Author
Points: 13,389, Level: 50 |
|
|
Join Date: Apr 2004
Location: Reading, Berks, United Kingdom.
Posts: 4,025
Thanks: 0
Thanked 114 Times in 112 Posts
|
|
There's an enormous literature on managing code-lists but you seem to be looking for a cheap-and-cheerful solution. In that case you might like to use XML entities: write the schema as
Code:
<!DOCTYPE xs:schema [
<!ENTITY codelist "codes.xml"/>
]>
<xs:schema>
<xs:simpleType name="categories">
<xs:restriction base="xs:normalizedString">
&codelist;
</xs:restriction>
</xs:simpleType>
and parse it using a SAX parser with a custom EntityResolver. When the parser tries to find codes.xml it will call your EntityResolver and you can return anything you like.
__________________
Michael Kay
http://www.saxonica.com/
Author, XSLT 2.0 and XPath 2.0 Programmer\'s Reference
|
|
The Following User Says Thank You to mhkay For This Useful Post:
|
|
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
 |