RSS
 

Transformation Config File expects Namespace Manager or XsltContext

12 May

What was happening?

I’m using custom config transformations in order to have different configs for each Azure deployment. You can modify your WebRole project like Alex Lambert showed us.

When using MSBuild we define a target that uses XMLTransform.


    

    
        
    

What was the error?

ServiceDefinition.Staging.csdef(3,15): error : Namespace Manager or XsltContext needed. This query has a prefix, variable, or user-defined function.

When working with code, you probably know what to do… But what if you’re having this in a Transformations config file?

The problem is that an Xpath expression was not found correctly.

We can directly trigger our target using the Visual Studio Command Prompt: “msbuild yourProject.cssproj /t:YourTargetName” to test this transformation. This was just failing over and over again, it kept me busy for hours because I was looking at the wrong spot. The errors in visual studio were also telling me that the attribute xdt:Transform was not declared. Even if the namespace import is present… xmlns:xdt=”http://schemas.microsoft.com/XML-Document-Transform” but that’s something you might ignore…

Whenever you have this error using Config Transformations  make sure you have the correct elements in your original config file that you are trying to transform using your transformations file. If an element could not be found, it will throw this exception.

Example

ServiceDefinition.csdef



  
    
      
        
          
        
      
    
    
      
    
    
      
    
    
      
    
     

ServiceDefinition.Staging.csdef



  
    
      
      
    
  

Whenever you make a mistake in the Locator Xpath that gets the Match you will receive the error (as you can see in MyWrongWeb).

 

Tags: , , , ,

Leave a Reply