@@ -461,7 +461,7 @@ static void DisplayValidationWarning(string fileName, string message, int column
461461 /// <summary>
462462 /// Applys the stylesheet to the xml and displays the resulting output.
463463 /// </summary>
464- public void RunXslTransform ( string xsl )
464+ public void RunXslTransform ( string xsl , string transformFileName )
465465 {
466466 try {
467467 SD . Workbench . GetPad ( typeof ( CompilerMessageView ) ) . BringPadToFront ( ) ;
@@ -472,9 +472,9 @@ public void RunXslTransform(string xsl)
472472 if ( editor == null ) return ;
473473
474474 if ( IsWellFormed ) {
475- if ( IsValidXsl ( xsl ) ) {
475+ if ( IsValidXsl ( xsl , transformFileName ) ) {
476476 try {
477- string transformedXml = Transform ( editor . Document . Text , xsl ) ;
477+ string transformedXml = Transform ( editor . Document . Text , xsl , transformFileName ) ;
478478 ShowTransformOutput ( transformedXml ) ;
479479 } catch ( XsltException ex ) {
480480 AddTask ( GetFileNameFromInnerException ( ex , StylesheetFileName ) , GetInnerExceptionErrorMessage ( ex ) , ex . LineNumber , ex . LinePosition , TaskType . Error ) ;
@@ -507,7 +507,7 @@ void ShowTransformOutput(string xml)
507507 /// <param name="input">The input xml to transform.</param>
508508 /// <param name="transform">The transform xml.</param>
509509 /// <returns>The output of the transform.</returns>
510- static string Transform ( string input , string transform )
510+ static string Transform ( string input , string transform , string transformFileName )
511511 {
512512 StringReader inputString = new StringReader ( input ) ;
513513 XmlTextReader sourceDocument = new XmlTextReader ( inputString ) ;
@@ -516,7 +516,7 @@ static string Transform(string input, string transform)
516516 XPathDocument transformDocument = new XPathDocument ( transformString ) ;
517517
518518 XslCompiledTransform xslTransform = new XslCompiledTransform ( ) ;
519- xslTransform . Load ( transformDocument , XsltSettings . TrustedXslt , new XmlUrlResolver ( ) ) ;
519+ xslTransform . Load ( transformDocument , XsltSettings . TrustedXslt , new XslTransformUrlResolver ( transformFileName ) ) ;
520520
521521 MemoryStream outputStream = new MemoryStream ( ) ;
522522 XmlTextWriter writer = new XmlTextWriter ( outputStream , Encoding . UTF8 ) ;
@@ -531,7 +531,7 @@ static string Transform(string input, string transform)
531531 /// <summary>
532532 /// Validates the given xsl string,.
533533 /// </summary>
534- bool IsValidXsl ( string xml )
534+ bool IsValidXsl ( string xml , string transformFileName )
535535 {
536536 try {
537537 SD . Workbench . GetPad ( typeof ( CompilerMessageView ) ) . BringPadToFront ( ) ;
@@ -540,13 +540,13 @@ bool IsValidXsl(string xml)
540540 XPathDocument doc = new XPathDocument ( reader ) ;
541541
542542 XslCompiledTransform xslTransform = new XslCompiledTransform ( ) ;
543- xslTransform . Load ( doc , XsltSettings . Default , new XmlUrlResolver ( ) ) ;
543+ xslTransform . Load ( doc , XsltSettings . Default , new XslTransformUrlResolver ( transformFileName ) ) ;
544544
545545 return true ;
546546 } catch ( XsltCompileException ex ) {
547547 AddTask ( StylesheetFileName , GetInnerExceptionErrorMessage ( ex ) , ex . LineNumber , ex . LinePosition , TaskType . Error ) ;
548548 } catch ( XsltException ex ) {
549- AddTask ( StylesheetFileName , ex . Message , ex . LinePosition , ex . LineNumber , TaskType . Error ) ;
549+ AddTask ( StylesheetFileName , GetInnerExceptionErrorMessage ( ex ) , ex . LinePosition , ex . LineNumber , TaskType . Error ) ;
550550 } catch ( XmlException ex ) {
551551 AddTask ( StylesheetFileName , ex . Message , ex . LinePosition , ex . LineNumber , TaskType . Error ) ;
552552 }
0 commit comments