diff --git a/RDFSharp/Query/Mirella/RDFQueryPrinter.cs b/RDFSharp/Query/Mirella/RDFQueryPrinter.cs index 66fb61db..f3673f14 100644 --- a/RDFSharp/Query/Mirella/RDFQueryPrinter.cs +++ b/RDFSharp/Query/Mirella/RDFQueryPrinter.cs @@ -270,21 +270,13 @@ internal static string PrintConstructQuery(RDFConstructQuery constructQuery) /// internal static string PrintAskQuery(RDFAskQuery askQuery) { - StringBuilder sb = new StringBuilder(); if (askQuery == null) - return sb.ToString(); + return string.Empty; - #region PREFIXES + StringBuilder sb = new StringBuilder(); List prefixes = PrintPrefixes(askQuery, sb, true); - #endregion - - #region ASK sb.AppendLine("ASK"); - #endregion - - #region WHERE PrintWhereClause(askQuery, sb, prefixes, string.Empty, 0, false); - #endregion return sb.ToString(); } @@ -451,6 +443,7 @@ internal static string PrintPatternGroup(RDFPatternGroup patternGroup, int space { //Begin new UNION block printingUnion = true; + result.AppendLine(string.Concat(spaces, " { ", PrintPattern(ptPgMember, prefixes), " }")); result.AppendLine(string.Concat(spaces, " UNION")); } @@ -458,10 +451,11 @@ internal static string PrintPatternGroup(RDFPatternGroup patternGroup, int space //Pattern is set as INTERSECT with the next pg member or it IS the last one => do not append UNION else { - //End active UNION block if (printingUnion) { + //End active UNION block printingUnion = false; + result.AppendLine(string.Concat(spaces, " { ", PrintPattern(ptPgMember, prefixes), " }")); } else @@ -473,10 +467,11 @@ internal static string PrintPatternGroup(RDFPatternGroup patternGroup, int space #region PROPERTY PATH else if (pgMember is RDFPropertyPath ppPgMember && ppPgMember.IsEvaluable) { - //End active UNION block if (printingUnion) { + //End active UNION block printingUnion = false; + result.AppendLine(string.Concat(spaces, " { ", PrintPropertyPath(ppPgMember, prefixes), " }")); } else @@ -487,10 +482,11 @@ internal static string PrintPatternGroup(RDFPatternGroup patternGroup, int space #region VALUES else if (pgMember is RDFValues vlPgMember && vlPgMember.IsEvaluable && !vlPgMember.IsInjected) { - //End active UNION block if (printingUnion) { + //End active UNION block printingUnion = false; + result.AppendLine(string.Concat(spaces, " { ", PrintValues(vlPgMember, prefixes, spaces), " }")); } else @@ -502,8 +498,8 @@ internal static string PrintPatternGroup(RDFPatternGroup patternGroup, int space else if (pgMember is RDFBind bdPgMember) { //End active UNION block - if (printingUnion) - printingUnion = false; + printingUnion = false; + result.AppendLine(string.Concat(spaces, " ", PrintBind(bdPgMember, prefixes), " .")); } #endregion