<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Xerces Whitespaces ignorieren!]]></title><description><![CDATA[<p>Moin!</p>
<p>Weiß jemand wie man in Xerces-C++ die Whitespaces zwischen den einzelnen Elementen ignoriert?!</p>
<pre><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
&lt;DI&gt;
	&lt;foo&gt;
		&lt;bar&gt;test123&lt;/bar&gt;
	&lt;/foo&gt;

&lt;/DI&gt;
</code></pre>
<p>So würde der Parser u.a. den ersten Whitespace zwischen dem root-Element und &lt;foo&gt; mitzählen.<br />
Ich finde keine Funktion in der API um diese Whitespaces zu ignorieren. Kann mir zwar ein Workaround basteln und auf TEXT_NODE etc. testen, ist aber etwas langwierig!</p>
<p>Gruß<br />
Sdy</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/239419/xerces-whitespaces-ignorieren</link><generator>RSS for Node</generator><lastBuildDate>Tue, 22 Sep 2026 12:34:28 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/239419.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 23 Apr 2009 09:46:42 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Xerces Whitespaces ignorieren! on Thu, 23 Apr 2009 11:39:56 GMT]]></title><description><![CDATA[<p>Moin!</p>
<p>Weiß jemand wie man in Xerces-C++ die Whitespaces zwischen den einzelnen Elementen ignoriert?!</p>
<pre><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
&lt;DI&gt;
	&lt;foo&gt;
		&lt;bar&gt;test123&lt;/bar&gt;
	&lt;/foo&gt;

&lt;/DI&gt;
</code></pre>
<p>So würde der Parser u.a. den ersten Whitespace zwischen dem root-Element und &lt;foo&gt; mitzählen.<br />
Ich finde keine Funktion in der API um diese Whitespaces zu ignorieren. Kann mir zwar ein Workaround basteln und auf TEXT_NODE etc. testen, ist aber etwas langwierig!</p>
<p>Gruß<br />
Sdy</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1700065</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1700065</guid><dc:creator><![CDATA[sheddy]]></dc:creator><pubDate>Thu, 23 Apr 2009 11:39:56 GMT</pubDate></item><item><title><![CDATA[Reply to Xerces Whitespaces ignorieren! on Thu, 23 Apr 2009 11:02:32 GMT]]></title><description><![CDATA[<p>Ich denk mal dass du mit Fragen zu Xerxes im Framework-Forum besser aufgehoben bist. Hier treibt sich eigentlich hauptsächlich Standard-C++ und boost etc. rum.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1700101</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1700101</guid><dc:creator><![CDATA[pumuckl]]></dc:creator><pubDate>Thu, 23 Apr 2009 11:02:32 GMT</pubDate></item><item><title><![CDATA[Reply to Xerces Whitespaces ignorieren! on Thu, 23 Apr 2009 11:55:55 GMT]]></title><description><![CDATA[<p>So Lösung gefunden! Da es mehrere Threads bei Google dazu gibt und ich keine Lösung darauf gefunden habe, poste ich mal die Lösung:</p>
<p>XSD:</p>
<pre><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
&lt;schema xmlns=&quot;http://www.w3.org/2001/XMLSchema&quot; targetNamespace=&quot;http://www.example.org/cfsh&quot; xmlns:tns=&quot;http://www.example.org/cfsh&quot; elementFormDefault=&quot;qualified&quot;&gt;

    &lt;element name=&quot;DI&quot; type=&quot;tns:bla&quot;&gt;&lt;/element&gt;

    &lt;complexType name=&quot;bla&quot;&gt;
    	&lt;sequence&gt;
    		&lt;element name=&quot;foo&quot; type=&quot;tns:NewType&quot;&gt;&lt;/element&gt;
    	&lt;/sequence&gt;
    &lt;/complexType&gt;

    &lt;complexType name=&quot;NewType&quot;&gt;
    	&lt;sequence&gt;
    		&lt;element name=&quot;bar&quot; type=&quot;string&quot; maxOccurs=&quot;1&quot; minOccurs=&quot;1&quot;&gt;&lt;/element&gt;
    	&lt;/sequence&gt;
    &lt;/complexType&gt;
&lt;/schema&gt;
</code></pre>
<p>XML:</p>
<pre><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
&lt;tns:DI xmlns:tns=&quot;http://www.example.org/cfsh&quot; xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot; xsi:schemaLocation=&quot;http://www.example.org/cfsh cfsh.xsd &quot;&gt;
  &lt;tns:foo&gt;
    &lt;tns:bar&gt;test&lt;/tns:bar&gt;
  &lt;/tns:foo&gt;
&lt;/tns:DI&gt;
</code></pre>
<p>1. Der Parser muss validieren können:<br />
<a href="http://xerces.apache.org/xerces-c/apiDocs-3/classAbstractDOMParser.html#993d73f69cbddfddfd959f80969f2fcc" rel="nofollow">http://xerces.apache.org/xerces-c/apiDocs-3/classAbstractDOMParser.html#993d73f69cbddfddfd959f80969f2fcc</a></p>
<pre><code class="language-cpp">parser_-&gt;setValidationScheme(XercesDOMParser::Val_Auto);
</code></pre>
<p>(ob Auto oder Always ist dabei egal)</p>
<p>2. Dann muss man dem Parser sagen, dass er das Schema auch parsen soll:<br />
<a href="http://xerces.apache.org/xerces-c/apiDocs-3/classAbstractDOMParser.html#60a217cdd2dc3cc38a0bde6672f67607" rel="nofollow">http://xerces.apache.org/xerces-c/apiDocs-3/classAbstractDOMParser.html#60a217cdd2dc3cc38a0bde6672f67607</a></p>
<pre><code class="language-cpp">parser_-&gt;setDoSchema(true);
</code></pre>
<p>3. Abhängigkeit zwischen den Namespaces und dem vorherigen Befehl:</p>
<blockquote>
<p>Note: If (void AbstractDOMParser::setDoSchema ( const bool newState ) ) set to true, namespace processing must also be turned on.</p>
</blockquote>
<p><a href="http://xerces.apache.org/xerces-c/apiDocs-3/classAbstractDOMParser.html#1962795fff331583b34b78229364ded7" rel="nofollow">http://xerces.apache.org/xerces-c/apiDocs-3/classAbstractDOMParser.html#1962795fff331583b34b78229364ded7</a></p>
<pre><code class="language-cpp">parser_-&gt;setDoNamespaces(true);
</code></pre>
<p>4. Ignorieren der Whitespaces:<br />
<a href="http://xerces.apache.org/xerces-c/apiDocs-3/classAbstractDOMParser.html#e3411bea02fd1e83b8f293854a5adc03" rel="nofollow">http://xerces.apache.org/xerces-c/apiDocs-3/classAbstractDOMParser.html#e3411bea02fd1e83b8f293854a5adc03</a></p>
<pre><code class="language-cpp">parser_-&gt;setIncludeIgnorableWhitespace(false);
</code></pre>
<p>Nochmal am Stück:</p>
<pre><code class="language-cpp">XercesDOMParser* parser_ = new XercesDOMParser;

parser_-&gt;setValidationScheme(XercesDOMParser::Val_Auto);
parser_-&gt;setDoSchema(true);
parser_-&gt;setDoNamespaces(true);
parser_-&gt;setIncludeIgnorableWhitespace(false);
</code></pre>
<p>Gruß Sdy</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1700114</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1700114</guid><dc:creator><![CDATA[sheddy]]></dc:creator><pubDate>Thu, 23 Apr 2009 11:55:55 GMT</pubDate></item></channel></rss>