|
@@ -70,13 +70,18 @@ Element::Element( Text string, Element *zParent )
|
|
|
{
|
|
|
if( string[ i ] == '\\' )
|
|
|
esc = !esc;
|
|
|
- if( string[ i ] == '"' && !esc )
|
|
|
+ else
|
|
|
{
|
|
|
- nameEnd = i + 1;
|
|
|
- break;
|
|
|
+ if( string[ i ] == '"' && !esc )
|
|
|
+ {
|
|
|
+ nameEnd = i + 1;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ esc = 0;
|
|
|
}
|
|
|
}
|
|
|
value.setText( string.getTeilText( start, nameEnd - 1 ) );
|
|
|
+ value.ersetzen( "\\\"", "\"" );
|
|
|
}
|
|
|
if( string[ nameEnd + 1 ] == '\'' )
|
|
|
{
|
|
@@ -86,13 +91,18 @@ Element::Element( Text string, Element *zParent )
|
|
|
{
|
|
|
if( string[ i ] == '\\' )
|
|
|
esc = !esc;
|
|
|
- if( string[ i ] == '\'' && !esc )
|
|
|
+ else
|
|
|
{
|
|
|
- nameEnd = i + 1;
|
|
|
- break;
|
|
|
+ if( string[ i ] == '\'' && !esc )
|
|
|
+ {
|
|
|
+ nameEnd = i + 1;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ esc = 0;
|
|
|
}
|
|
|
}
|
|
|
value.setText( string.getTeilText( start, nameEnd - 1 ) );
|
|
|
+ value.ersetzen( "\\'", "'" );
|
|
|
}
|
|
|
setAttribute( attrName->getText(), value );
|
|
|
}
|
|
@@ -151,11 +161,7 @@ Element::Element( Text string, Element *zParent )
|
|
|
break;
|
|
|
case '<':
|
|
|
if( !inString1 && !inString2 )
|
|
|
- {
|
|
|
- if( poc == 0 )
|
|
|
- lastOpen = 1;
|
|
|
- poc++;
|
|
|
- }
|
|
|
+ lastOpen = 1;
|
|
|
esc = 0;
|
|
|
lastSlash = 0;
|
|
|
break;
|
|
@@ -173,8 +179,11 @@ Element::Element( Text string, Element *zParent )
|
|
|
case '>':
|
|
|
if( !inString1 && !inString2 )
|
|
|
{
|
|
|
- poc--;
|
|
|
- if( poc == 0 && (lastSlash || openSlash) )
|
|
|
+ if( openSlash )
|
|
|
+ poc--;
|
|
|
+ else if( !lastSlash )
|
|
|
+ poc++;
|
|
|
+ if( poc == 0 )
|
|
|
{
|
|
|
Text *str = text->getTeilText( start, i + 1 );
|
|
|
addChild( new Element( str->getText(), this ) );
|
|
@@ -189,7 +198,10 @@ Element::Element( Text string, Element *zParent )
|
|
|
default:
|
|
|
esc = 0;
|
|
|
if( text->getText()[ i ] != ' ' && text->getText()[ i ] != '\t' && text->getText()[ i ] != '\r' && text->getText()[ i ] != '\n' )
|
|
|
+ {
|
|
|
lastSlash = 0;
|
|
|
+ lastOpen = 0;
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -197,6 +209,8 @@ Element::Element( Text string, Element *zParent )
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+ else
|
|
|
+ text->setText( "" );
|
|
|
}
|
|
|
}
|
|
|
parent = zParent;
|
|
@@ -442,13 +456,30 @@ Text Element::toString() const
|
|
|
{
|
|
|
Text ret = "<";
|
|
|
ret += name->getText();
|
|
|
- ret += " ";
|
|
|
+ if( attributes->getEintragAnzahl() )
|
|
|
+ ret += " ";
|
|
|
for( auto i = attributes->getIterator(), j = attributeValues->getIterator(); i && j; i++, j++ )
|
|
|
{
|
|
|
ret += i->getText();
|
|
|
- ret += "=\"";
|
|
|
- ret += j->getText();
|
|
|
- ret += "\"";
|
|
|
+ if( j->getLength() )
|
|
|
+ {
|
|
|
+ if( j->hat( '"' ) )
|
|
|
+ {
|
|
|
+ ret += "='";
|
|
|
+ Text txt = j->getText();
|
|
|
+ txt.ersetzen( "'", "\\'" );
|
|
|
+ ret += txt;
|
|
|
+ ret += "'";
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ ret += "=\"";
|
|
|
+ Text txt = j->getText();
|
|
|
+ txt.ersetzen( "\"", "\\\"" );
|
|
|
+ ret += txt;
|
|
|
+ ret += "\"";
|
|
|
+ }
|
|
|
+ }
|
|
|
if( i.hasNext() )
|
|
|
ret += " ";
|
|
|
}
|