Hello,
I want to load a grammar which doesnt not come with a DOCTYPE
declaration,
I tried with those lines, and it doesn't work
parser->setFeature(XML Uni::fgSAX2Core Validation, true);
parser->setFeature(XML Uni::fgSAX2Core NameSpaces, false)
// Load grammar and cache it
parser->loadGrammar(/path/to/my/file.dtd", Grammar::DTDGra mmarType,
true);
// enable grammar reuse
parser->setFeature(XML Uni::fgXercesUs eCachedGrammarI nParse, true);
Actually, If the <! DOCTYPE validation SYSTEM "file.dtd" > declaration
is present, it does the validation with the file in the current path,
not the one I loaded in cache.
if the <! DOCTYPE ... > is not there, it does not validate.
for example, it would be nice if it were possible to override a DOCTYPE
declaration
Thank You,
Delphin 2 2531
Hi Delphin, de************@ gmail.com writes: Hello,
I want to load a grammar which doesnt not come with a DOCTYPE declaration,
I tried with those lines, and it doesn't work
parser->setFeature(XML Uni::fgSAX2Core Validation, true); parser->setFeature(XML Uni::fgSAX2Core NameSpaces, false)
What happens if you also add these?
parser->setFeature(XML Uni::fgXercesDy namic, false);
parser->setFeature(XML Uni::fgXercesSc hema, true);
parser->setFeature(XML Uni::fgXercesSc hemaFullCheckin g, true); // Load grammar and cache it parser->loadGrammar(/path/to/my/file.dtd", Grammar::DTDGra mmarType, true); // enable grammar reuse parser->setFeature(XML Uni::fgXercesUs eCachedGrammarI nParse, true);
Actually, If the <! DOCTYPE validation SYSTEM "file.dtd" > declaration is present, it does the validation with the file in the current path, not the one I loaded in cache. if the <! DOCTYPE ... > is not there, it does not validate.
for example, it would be nice if it were possible to override a DOCTYPE declaration
My understanding is that the loadGrammar works as a proxy to entity
resolver. In other words, when the parser sees
<! DOCTYPE validation SYSTEM "file.dtd" >
it normally calls entity resolver to locate file.dtd but before that it
consults the grammar cache to see if this grammar was already loaded.
So I think the reason why if does not work is because without the
above DOCTYPE there is nothing in the document that specifies against
which schema we should validate (note that nothing prevents you from
caching several unrelated schemas). In case of XML Schema, there is
the fgXercesSchemaE xternalSchemaLo cation property that allows you
to specify schemas for namespaces and thus trigger validation if
a document refers to one of those namespaces. In case of DTD, I don't
see any similar mechanism. You may also find the following article
interesting: http://www-128.ibm.com/developerwork...x-xsdxerc.html
hth,
-boris
--
Boris Kolpackov
Code Synthesis Tools CC http://www.codesynthesis.com
Open-Source, Cross-Platform C++ XML Data Binding
Hi Boris!
My understanding is that the loadGrammar works as a proxy to entity
resolver. In other words, when the parser sees
<! DOCTYPE validation SYSTEM "file.dtd" > it normally calls entity resolver to locate file.dtd but before that it consults the grammar cache to see if this grammar was already loaded. So I think the reason why if does not work is because without the above DOCTYPE there is nothing in the document that specifies against which schema we should validate (note that nothing prevents you from caching several unrelated schemas). In case of XML Schema, there is the fgXercesSchemaE xternalSchemaLo cation property that allows you to specify schemas for namespaces and thus trigger validation if a document refers to one of those namespaces. In case of DTD, I don't see any similar mechanism. You may also find the following article interesting:
http://www-128.ibm.com/developerwork...x-xsdxerc.html
hth, -boris -- Boris Kolpackov Code Synthesis Tools CC http://www.codesynthesis.com Open-Source, Cross-Platform C++ XML Data Binding
Thank you for your help, the article was interesting, but I wanted to
use DTD rather XSD because it is more simple and it is sufficient for
my project.
I finaly choosed to pass the DTD file name in the XML file this way :
<! DOCTYPE rootElement SYSTEM "relativeFileNa me.dtd" >
I have overloaded MyHandler::reso lveEntity to return a
LocalFileInputS ource using the application specific basePath and the
relativeFileNam e given in the XML Document.
//dtdPath is a member of MySAX2Handler that I init before to parse
void MySAX2Handler:: setDTDPath(cons t char* dtdPath_) { dtdPath =
dtdPath_;}
InputSource* MySAX2Handler:: resolveEntity(
const XMLCh *const publicId, const XMLCh *const systemId) {
XMLCh* transcoded = XMLString::tran scode(dtdPath);
InputSource* inSrc = new LocalFileInputS ource(transcode d,
systemId,
XMLPlatformUtil s::fgMemoryMana ger);
XMLString::rele ase(&transcoded );
return inSrc;
}
This way it works, but it does not seem to be the perfect solution.
Delphin This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Bekkali Hicham |
last post by:
hi, i have downloaded the latest version 2.4 of Xerces, and unziped it, i
end up with a diectory hierarchy like this
c:\xerces-2_4_0\XercesImpl.jar
c:\xerces-2_4_0\XercesSamples.jar
c:\xerces-2_4_0\xml-apis.jar
c:\xerces-2_4_0\xmlParserAPIS.jar
c:\xerces-2_4_0\data
c:\xerces-2_4_0\docs
c:\xerces-2_4_0\samples
there is no bin directory, my question is :
|
by: Stu |
last post by:
I am trying to build the xerces shared library with 2.3.0 version of
their source code on an AIX 5.1 32 bit machine with the following
version of the g++ compiler
/usr/local/bin/g++ -v
Reading specs from /usr/local/lib/gcc-lib/powerpc-ibm-aix5.1.0.0/3.3.1/specs
Configured with: ../gcc-3.3.1/configure --disable-nls
Thread model: aix
gcc version 3.3.1
|
by: Waseem |
last post by:
Hi
I have looked and tried everything and i still cant sort this out i
have no idea why this wont work
I am using Xerces Perl on Windows and Debian to try this and it wont
work on both of them.
Basically i am tryin to do simple tree transversale and get the node
values out
|
by: Jim Phelps |
last post by:
After having memory leak issues with Xerces-c 2.3.0 for Solaris 2.7
for CC 6.2 I have decided to update to at least 2.4. I have
downloaded the binary tarball and have installed it on my development
server, which runs Solaris 2.8. I do use CC 6.2 for my compiler. I
have reset all the environment variables in Korn shell that point to
the Xerces distribution.
When I try to compile the same piece of code that compiles fine under
Xerces...
|
by: Dale Gerdemann |
last post by:
I've been trying to use DOM level 3 with xerces-2_6_2. There's a
sample called samples/DOM3.java, but I've had trouble with
compilation. I've downloaded Xerces-J-bin.2.6.2 and
beta2-dom3-Xerces-J-bin.2.6 and added the following paths to my CLASSPATH:
..../xerces-2_6_2/xercesImpl.jar:
..../xerces-2_6_2/dom3-xercesImpl.jar:
..../xerces-2_6_2/dom3-xml-apis.jar:
..../xerces-2_6_2/xmlParserAPIs.jar:
..../xerces-2_6_2/xercesSamples.jar:
| |
by: jacksu |
last post by:
I have a simple program to run xpath with xerces 1_2_7
XPathFactory factory = XPathFactory.newInstance();
XPath xPath = factory.newXPath();
XPathExpression xp = xPath.compile(strXpr);
System.out.println(xp.evaluate(new InputSource(new
FileInputStream("a.xml"))));
|
by: Matt |
last post by:
Hello,
Summary:
Where can one download a Xerces-C (XML pardser) dynamic library file
(.DLL file) for Windows (Win98/WinNT/Win2k/WinXP/Win2003, including
server flavors; don't need to support pre-98) without having to build
the library from source?
We posed this question to the Xerces-users email list, but have yet to
|
by: Vlad Zorinov |
last post by:
I'm getting the following error after a couple of months of XML processing, using Xerces 2.0.0 in an apache tomcat. Does anyone have any ideas what this problem may be or what I should do to solve it?
cheers,
Vlad
The exception is...
tv.ditg.sdl.ParsingException:
tv.ditg.sdl.ParsingException:
|
by: Raphael Tagliani |
last post by:
(english version below)
Bonjour!
Je travaille sur un gros projet java, qui parse beaucoup de fichiers xml
au lancement d'un serveur.
Nous avons un problème de concurrence qu lancement.
En fait, il s'agit d'une erreur Xerces FWK005, et nous sommes incapables
de trouver d'où elle provient dans le code. Nous avons déjà essayé de
rendre toutes les méthodes qui appellent Xerces synchronized, mais celà
|
by: mstilli |
last post by:
Hi,
I am trying to use schema for server side validation using xerces to
catch the validation errors.
validating this XML:
<Content4>
<textarea13></textarea13>
<binaryobject3></binaryobject3>
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
| |
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
| |
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
| |