p2p.wrox.com Forums

Need to download code?

View our list of code downloads.

Free Code from Wrox
Go Back   p2p.wrox.com Forums > XML > XML
I forgot my password
Register Now
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 .
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old July 1st, 2009, 12:22 PM
Registered User
Points: 22, Level: 1
Points: 22, Level: 1 Points: 22, Level: 1 Points: 22, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2009
Posts: 5
Thanks: 1
Thanked 0 Times in 0 Posts
Default 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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #2 (permalink)  
Old July 1st, 2009, 12:28 PM
samjudson's Avatar
Friend of Wrox
Points: 4,955, Level: 29
Points: 4,955, Level: 29 Points: 4,955, Level: 29 Points: 4,955, Level: 29
Activity: 82%
Activity: 82% Activity: 82% Activity: 82%
 
Join Date: Aug 2007
Location: Newcastle, , United Kingdom.
Posts: 1,453
Thanks: 0
Thanked 50 Times in 50 Posts
Default

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 -/
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #3 (permalink)  
Old July 1st, 2009, 12:46 PM
Registered User
Points: 22, Level: 1
Points: 22, Level: 1 Points: 22, Level: 1 Points: 22, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2009
Posts: 5
Thanks: 1
Thanked 0 Times in 0 Posts
Default

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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #4 (permalink)  
Old July 1st, 2009, 12:52 PM
mhkay's Avatar
Wrox Author
Points: 13,389, Level: 50
Points: 13,389, Level: 50 Points: 13,389, Level: 50 Points: 13,389, Level: 50
Activity: 82%
Activity: 82% Activity: 82% Activity: 82%
 
Join Date: Apr 2004
Location: Reading, Berks, United Kingdom.
Posts: 4,025
Thanks: 0
Thanked 114 Times in 112 Posts
Default

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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
The Following User Says Thank You to mhkay For This Useful Post:
bribon (July 1st, 2009)
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Parse and Format XML areed24 ASP.NET 3.5 Basics 2 May 4th, 2009 06:57 AM
Parse xml (with validation) blackbird XML 2 October 2nd, 2007 09:27 AM
Parse XML response atulb XML 1 October 30th, 2005 07:05 AM
about XML receive by tomcatand XML parse by java taianmhzy Servlets 0 May 20th, 2004 02:59 AM
about XML receive ang XML parse by tomcat taianmhzy Apache Tomcat 0 May 20th, 2004 02:56 AM



All times are GMT -4. The time now is 09:33 AM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
© 2010 Wiley Publishing, Inc