@@ -483,6 +483,7 @@ private static string ValidatePerSchema(XElement element)
483
483
<xs:element name='Table'>
484
484
<xs:complexType>
485
485
<xs:attribute name='Select' type='xs:string' use='required' />
486
+ <xs:attribute name='Optional' type='xs:boolean' use='optional' />
486
487
</xs:complexType>
487
488
</xs:element>
488
489
</xs:schema>" ,
@@ -521,6 +522,7 @@ private static string ValidatePerSchema(XElement element)
521
522
<xs:attribute name='Select' type='xs:string' use='required' />
522
523
<xs:attribute name='Match' type='xs:string' use='optional' />
523
524
<xs:attribute name='NotMatch' type='xs:string' use='optional' />
525
+ <xs:attribute name='Optional' type='xs:boolean' use='optional' />
524
526
</xs:complexType>
525
527
</xs:element>
526
528
</xs:schema>" ,
@@ -692,6 +694,10 @@ static object ContentReplacementTransform(XNode node, XElement data, TemplateErr
692
694
}
693
695
if ( tableData . Count ( ) == 0 )
694
696
return CreateContextErrorMessage ( element , "Table Select returned no data" , templateError ) ;
697
+
698
+ var optionalString = ( string ) element . Attribute ( PA . Optional ) ;
699
+ bool optional = ( optionalString != null && optionalString . ToLower ( ) == "true" ) ;
700
+
695
701
XElement table = element . Element ( W . tbl ) ;
696
702
XElement protoRow = table . Elements ( W . tr ) . Skip ( 1 ) . FirstOrDefault ( ) ;
697
703
var footerRowsBeforeTransform = table
@@ -720,7 +726,7 @@ static object ContentReplacementTransform(XNode node, XElement data, TemplateErr
720
726
string newValue = null ;
721
727
try
722
728
{
723
- newValue = EvaluateXPathToString ( d , xPath , false ) ;
729
+ newValue = EvaluateXPathToString ( d , xPath , optional ) ;
724
730
}
725
731
catch ( XPathException e )
726
732
{
@@ -750,6 +756,8 @@ static object ContentReplacementTransform(XNode node, XElement data, TemplateErr
750
756
string xPath = ( string ) element . Attribute ( PA . Select ) ;
751
757
var match = ( string ) element . Attribute ( PA . Match ) ;
752
758
var notMatch = ( string ) element . Attribute ( PA . NotMatch ) ;
759
+ var optionalString = ( string ) element . Attribute ( PA . Optional ) ;
760
+ bool optional = ( optionalString != null && optionalString . ToLower ( ) == "true" ) ;
753
761
754
762
if ( match == null && notMatch == null )
755
763
return CreateContextErrorMessage ( element , "Conditional: Must specify either Match or NotMatch" , templateError ) ;
@@ -760,7 +768,7 @@ static object ContentReplacementTransform(XNode node, XElement data, TemplateErr
760
768
761
769
try
762
770
{
763
- testValue = EvaluateXPathToString ( data , xPath , false ) ;
771
+ testValue = EvaluateXPathToString ( data , xPath , optional ) ;
764
772
}
765
773
catch ( XPathException e )
766
774
{
0 commit comments