Commit 75aa629d authored by tebjan's avatar tebjan
Browse files

Merge remote-tracking branch 'origin/master' into textEvents

parents 9fd53516 3fb1b28b
...@@ -215,15 +215,11 @@ namespace Svg ...@@ -215,15 +215,11 @@ namespace Svg
element = svgDocument; element = svgDocument;
} }
if (element == null)
{
continue;
}
// Add to the parents children // Add to the parents children
if (elementStack.Count > 0) if (elementStack.Count > 0)
{ {
parent = elementStack.Peek(); parent = elementStack.Peek();
if (parent != null && element != null)
parent.Children.Add(element); parent.Children.Add(element);
} }
...@@ -236,11 +232,17 @@ namespace Svg ...@@ -236,11 +232,17 @@ namespace Svg
goto case XmlNodeType.EndElement; goto case XmlNodeType.EndElement;
} }
if (element == null)
{
continue;
}
break; break;
case XmlNodeType.EndElement: case XmlNodeType.EndElement:
// Skip if no element was created and is not the closing tag for the last // Skip if no element was created and is not the closing tag for the last
// known element // known element
if (element == null && reader.LocalName != elementStack.Peek().ElementName) SvgElement topElement = elementStack.Peek();
if (element == null && (topElement != null && reader.LocalName != topElement.ElementName))
{ {
continue; continue;
} }
...@@ -249,6 +251,7 @@ namespace Svg ...@@ -249,6 +251,7 @@ namespace Svg
if (value.Length > 0) if (value.Length > 0)
{ {
if (element != null)
element.Content = value.ToString(); element.Content = value.ToString();
// Reset content value for new element // Reset content value for new element
value = new StringBuilder(); value = new StringBuilder();
......
...@@ -14,6 +14,7 @@ namespace Svg ...@@ -14,6 +14,7 @@ namespace Svg
internal class SvgElementFactory internal class SvgElementFactory
{ {
private static List<ElementInfo> availableElements; private static List<ElementInfo> availableElements;
private const string svgNS = "http://www.w3.org/2000/svg";
/// <summary> /// <summary>
/// Gets a list of available types that can be used when creating an <see cref="SvgElement"/>. /// Gets a list of available types that can be used when creating an <see cref="SvgElement"/>.
...@@ -77,9 +78,12 @@ namespace Svg ...@@ -77,9 +78,12 @@ namespace Svg
{ {
SvgElement createdElement = null; SvgElement createdElement = null;
string elementName = reader.LocalName; string elementName = reader.LocalName;
string elementNS = reader.NamespaceURI;
//Trace.TraceInformation("Begin CreateElement: {0}", elementName); //Trace.TraceInformation("Begin CreateElement: {0}", elementName);
if (elementNS == svgNS)
{
if (elementName == "svg") if (elementName == "svg")
{ {
createdElement = (fragmentIsDocument) ? new T() : new SvgFragment(); createdElement = (fragmentIsDocument) ? new T() : new SvgFragment();
...@@ -97,6 +101,7 @@ namespace Svg ...@@ -97,6 +101,7 @@ namespace Svg
{ {
SetAttributes(createdElement, reader, document); SetAttributes(createdElement, reader, document);
} }
}
//Trace.TraceInformation("End CreateElement"); //Trace.TraceInformation("End CreateElement");
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment