This week's book giveaway is in the Kotlin forum.
We're giving away four copies of Kotlin in Action and have Dmitry Jemerov & Svetlana Isakova on-line!
See this thread for details.
Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

How to dynmically determine the system ID  RSS feed

Dhiren Joshi
Ranch Hand
Posts: 463
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have to parser an xml which has to be validated against an xsd.
EG. . XML..1 xsd is request.xsd
private static String request="<?xml version=\"1.0\" encoding=\"UTF-8\"?><request xmlns:xsi=\"\" xsi:noNamespaceSchemaLocation=\"request.xsd\" debug=\"T\"><appid id=\"AppId\"></appid><platform id=\"4\"></platform</request>" ;
EG. . XML..2 xsd is retrieve.xsd
private static String request="<?xml version=\"1.0\" encoding=\"UTF-8\"?><retrieve xmlns:xsi=\"\" xsi:noNamespaceSchemaLocation=\"retrieve.xsd\" debug=\"T\"><retrieve-appid id=\"AppId\"></retrieve-appid><retrieve-platform id=\"6\"></retrieve-platform</retrieve>" ;

How can I let the parser dynamically determine the xsd to use depending on what the xml I pass . I dont want to hardcode the xsd values into the parser .

For DTD I used parser.setEntityResolver(EntityResolver res) .. Does this work for xsd's too if so can some please paste a code snippet how the parser validates against xsd's dynamically.
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!