how to debug xslt in umbraco - xslt

I want to debug a xslt used in umbraco (4.0) user control. The xslt is using static .net methods from an assembly say MyAssembly. The xslExtensions.config has been setup with the following entry <ext assembly="/bin/MyAssembly" type="MyAssembly.Utility" alias="MyAssembly.Utility" />
This is referenced and used in the xslt file like
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:MyAssembly.Utility="urn:MyAssembly.Utility"....
-------------------------------------------------->
--------------------------------------------------
<xsl:variable name="Id" select="MyAssembly.Utility:GetQueryStringValue('tlid')"></xsl:variable>
The assembly is copied in the bin folder of the application
The xslt file is quite big and extensively using .net methods. I'm just wondering how can I debug the XSLT by adding breakpoints at various lines. If I run the application just like any .net application and put break points then these breakpoints don't get a hit. If I use the XSLT debug options from the Visual studio menu i.e. Start XSLT Debugging then the debugging starts but I get the error on this line <xsl:variable name="Id" select="MyAssembly.Utility:GetQueryStringValue('tlid')"></xsl:variable>
the error is "Cannot find a script or an extension object associated with namespace 'urn:MyAssembly.Utility'."
Any ideas how can we debug the xslt as explained in this MS visual studio walk-through https://msdn.microsoft.com/en-us/library/ms255602.aspx using .net methods?

I have never used XSLT so i'm probably not going to help with what I'm going to say, but since I've been doing this since day 1 why don't you use break points in Visual Studio to see what your code does? That's the only way I've needed so far in debugging my code.

Related

natvis in vscode with gdb gives "Explicit refresh required for visualized expressions"

vscode is meant to be able to pretty print custom objects if given a natvis file. I'm running linux and debugging with gdb.
The docs say:
For gdb/lldb debugging ("type": "cppdbg"), a subset of the Natvis framework has been ported to the Visual Studio Code C/C++ extension and the code resides in the MIEngine shared component. If additional features that are not implemented are requested, please file an issue on the MIEngine GitHub page with details of what is missing.
I've created a simple natvis file based on the natvis page here:
<?xml version="1.0" encoding="utf-8"?>
<AutoVisualizer xmlns="http://schemas.microsoft.com/vstudio/debugger/natvis/2010">
<Type Name="MyArray">
<DisplayString>{{size={size}}}</DisplayString>
<Expand>
<Item Name="[size]">size</Item>
<ArrayItems>
<Size>size</Size>
<ValuePointer>ptr</ValuePointer>
</ArrayItems>
</Expand>
</Type>
</AutoVisualizer>
I've included a reference to this file in my launch.json:
"visualizerFile": "${workspaceFolder}/file.natvis",
After launching the debugger and hovering over a variable I see "Explicit refresh required for visualized expressions". This was promising because it shows vscode has found the file, but it still isn't able to apply it for some reason. There are no natvis logs/errors in any of the vscode OUTPUT/DEBUG CONSOLE tabs.
Is there something I'm missing? How can I get vscode+gdb to use my .natvis file?
The solution for me came from here:
can you make sure you have the property "showDisplayString": true set in your launch.json?
Adding the following line in addition to visualizerFile suddenly made the .natvis definitions work.
"visualizerFile": "${workspaceFolder}/file.natvis",
"showDisplayString": true, // <-- add this
FYI, I also noticed that vscode passes --interpreter=mi to gdb, so there is some explicit gdb support for interacting with the MIEngine referenced by the docs.

SSDT Project ille warning on Invalid Child Element IncludeCompositeObjects

I'm working on an SSDT project. The publish script looks like this:
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<IncludeCompositeObjects>True</IncludeCompositeObjects>
<TargetDatabaseName>VisionStaging</TargetDatabaseName>
<DeployScriptFileName>VisionStaging.sql</DeployScriptFileName>
<TargetConnectionString>xxxx</TargetConnectionString>
<BlockOnPossibleDataLoss>True</BlockOnPossibleDataLoss>
<CreateNewDatabase>True</CreateNewDatabase>
<ProfileVersionNumber>1</ProfileVersionNumber>
<IgnoreColumnOrder>True</IgnoreColumnOrder>
<IgnorePartitionSchemes>True</IgnorePartitionSchemes>
</PropertyGroup>
<ItemGroup>
<SqlCmdVariable Include="master">
<Value>master</Value>
</SqlCmdVariable>
</ItemGroup>
</Project>
When I open this file in Visual Studio, a few warnings appear:
The element 'PropertyGroup' in namespace
'http://schemas.microsoft.com/developer/msbuild/2003' has invalid
child element 'IncludeCompositeObjects' in namespace
'http://schemas.microsoft.com/developer/msbuild/2003'
The element 'ItemGroup' in namespace
'http://schemas.microsoft.com/developer/msbuild/2003' has invalid
child element 'SqlCmdVariable' in namespace
'http://schemas.microsoft.com/developer/msbuild/2003'.
The element 'Project' in namespace
'http://schemas.microsoft.com/developer/msbuild/2003' has incomplete
content.
I suppose the last one is caused by the first two. Any idea how to get rid of these warnings? Note that these files were built by the SSDT plugin which is 15.1.61902.21100 and VS does not show that any updates are available for it. In other words, the SSDT plugin put these elements in the file, not me.
PropertyGroup Contains a set of user-defined Property elements.
Validation of the schema in this case MSBuild schema in the Visual Studio IDE does not correctly handle custom properties, So if you have your publish.xml file open, you will always get a warning on the first custom item under PropertyGroup such as IncludeCompositeObjects
It shouldn't cause any problems, since you can define your own properties, They should only appear when you open the publish.xml file for editing in the IDE.
If you make your edits and close the file, they should go away.

Code running in OXYGEN correctly but not in altova

I've an XML document, on which i was running an XSLT.
when i run it in Oxygen, the output is fine, but when i do the same in Altova, it is catching wrong when and giving a buggy output. When i went into the XML engine, it showed it as SAXON HE and in Altova i think it used XALAN, I tried to import the SAXON jar file and tere the parameters expected are %1(XML input), %2(Output File) and %3(XSL), but here the problem is i'm running on an entire set of files from project window.
CAn you please let me know how i can fix this issue and use Saxon to run multiple files.
Thanks
Xalan does not support XSLT2.0. Saxon implements XSLT2.0. The arguments for saxon should be
-xsl:<xsl file> -s:<input xml> -o:<output file>
More here: http://www.saxonica.com/documentation9.5/using-xsl/commandline.html

Can partial config files linked to a web.config via configSource be transformed in a web project?

Looking for some help from anyone that's worked with SlowCheetah to transform config files under a web project. We're finding that partial config files referenced from the web.config are not being transformed.
For example, we've included references to partial configs AppSettings.config and ConnectionsString.config in the web.config like so:
</system.web>
<connectionStrings configSource ="ConnectionsString.config"></connectionStrings>
<appSettings configSource ="AppSettings.config"></appSettings>
</configuration>
and then in the AppSettings.config we have just the AppSettings section like so:
<appSettings>
<add key="LostPasswordBCC" value="knock#timmons.com" />
</appSettings>
and finally in the transform file AppSettings.Debug.config we have some additions:
<?xml version="1.0" encoding="utf-8" ?>
<!-- For more information on using transformations
see the web.config examples at http://go.microsoft.com/fwlink/?LinkId=214134. -->
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
<appSettings >
<add key="Release" value="Something" xdt:Transform="Insert" />
</appSettings>
</configuration>
Obviously the above is just a test to see the transform occur, but what we're finding is that on attempting to preview the transform all we get back is an error "There was an error processing the transformation." The publish attempt also fails.
If we make the config files fully formed xml and not referenced from web.config, the transformation seems to work fine - but were looking to share these files across multiple projects.
Does anyone know if there's a workaround where we can both reference partial configs from the web.config and also have transforms off those partial files? We're dealing with legacy code with a large number of config files across multiple web projects that were attempting to consolidate, thus the need to link from web config to separate shared files.
Problem has been resolved, turns out after help from Sayed, we determined that in our efforts to understand the config transformation process with a web project we had corrupted the transform config file's format. With freshly created config files we were able to get transforms to work using SlowCheetah.
This allowed us to move on the real problem we needed to address which was wanting to transform project configs other than the web.config using Visual Studio 2012's publish profiles. This did not work originally, but again Sayed helped us out and provided a new copy of SlowCheetah that allowed this to work.
Below is a link to the new version of SlowCheetah with the fix: https://github.com/sayedihashimi/slow-cheetah/issues/46
Much thanks for all your time and patience Sayed.

MSBuild: Custom.After.Microsoft.Common.targets for native C++ projects in VS2010

I've read about the use of "Custom.Before.Microsoft.Common.targets" and "Custom.After.Microsoft.Common.targets" in order to execute a custom target before/after every project build and I would like to use this technique in order to change version info while building on our TeamCity build server.
The problem is that although it works for C# projects, it doesn't seem to work for native C++ projects.
After some digging around in the Microsoft.Cpp.targets file I found out that for native C++ projects this seems to be implemented through setting $(ForceImportBeforeCppTargets) and $(ForceImportAfterCppTargets).
I can't seem to find a single piece of information on the web about this technique for native C++ apps though, so I'm asking if I'm looking in the right direction or not.
Any help is appreciated.
For VC++ projects it is a bit different. You define a file to be imported either at the beginning or at the end of the project. To use this approach you need to define values for the properties ForceImportBeforeCppTargets or ForceImportAfterCppTargets. For example if you want a file to be included at the beginning of the project you can pass in the value at the command line. For example I just created a dummy VC++ project named CppTets01. Then I created the two sample files below.
Before.proj
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Target Name="CustomTargetInBefore" AfterTargets="Build">
<Message Text="From CustomTargetInBefore" Importance="high"/>
</Target>
</Project>
After.proj
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Target Name="CustomTargetInAfter" AfterTargets="Build">
<Message Text="From CustomTargetInAfter" Importance="high"/>
</Target>
</Project>
Then I executed the following command:
msbuild CppTest01.vcxproj
/p:ForceImportBeforeCppTargets="C:\Temp\_NET\ThrowAway\CppTest01\CppTest01\Before.proj";
ForceImportAfterCppTargets="C:\Temp\_NET\ThrowAway\CppTest01\CppTest01\After.proj"
The result was
C:\Temp_NET\ThrowAway\CppTest01\CppTest01>msbuild CppTest01.vcxproj /p:ForceImportBeforeCppTargets="C:\Temp_NET\ThrowAway\CppTest01\C
ppTest01\Before.proj";ForceImportAfterCppTargets="C:\Temp_NET\ThrowAway\CppTest01\CppTest01\After.proj"
Microsoft (R) Build Engine Version 4.0.30319.1
[Microsoft .NET Framework, Version 4.0.30319.1]
Copyright (C) Microsoft Corporation 2007. All rights reserved.
Build started 10/18/2010 8:32:55 AM.
Project "C:\Temp\_NET\ThrowAway\CppTest01\CppTest01\CppTest01.vcxproj" on node 1 (default targets).
InitializeBuildStatus:
Creating "Debug\CppTest01.unsuccessfulbuild" because "AlwaysCreate" was specified.
ClCompile:
All outputs are up-to-date.
All outputs are up-to-date.
ManifestResourceCompile:
All outputs are up-to-date.
Link:
All outputs are up-to-date.
Manifest:
All outputs are up-to-date.
FinalizeBuildStatus:
Deleting file "Debug\CppTest01.unsuccessfulbuild".
Touching "Debug\CppTest01.lastbuildstate".
CustomTargetInBefore:
From CustomTargetInBefore
CustomTargetInAfter:
From CustomTargetInAfter
Done Building Project "C:\Temp\_NET\ThrowAway\CppTest01\CppTest01\CppTest01.vcxproj" (default targets).
Build succeeded.
0 Warning(s)
0 Error(s)
Time Elapsed 00:00:00.21
As you can see from the output the targets were successfully injected into the build process. If you want to relate this back to Custom.Before.Microsoft.Common.targets and Custom.Before.Microsoft.Common.targets then you should know that the technique used there is a bit different. Specifically if you create those files they are automatically imported into every C#/VB.NET project. In this case you have to set this property. You really have two options here:
You can set this property as an environment variable
You can use another technique, ImportBefore & ImportAfter which is specific to VC++
For #1 let me explain a bit. In MSBuild when you access a property with the syntax $(PropName) then if a property with the name PropName doesn't exist MSBuild will look up in the environment variables to see if such a value exists, if it does then that value is returned. So if you have a build server in which you want to include a file for each VC++ build, then just create those properties as environment variables. Now for the other technique.
ImportBefore/ImportAfter
In VC++ a new concept is introduced. In Microsoft.Cpp.Win32.targets you can see the declaration at the top of the .targets file.
<Import Project="$(VCTargetsPath)\Platforms\Win32\ImportBefore\*.targets"
Condition="Exists('$(VCTargetsPath)\Platforms\Win32\ImportBefore')" />
Then there is one towards the bottom
<Import Project="$(VCTargetsPath)\Platforms\Win32\ImportAfter\*.targets"
Condition="Exists('$(VCTargetsPath)\Platforms\Win32\ImportAfter')" />
A similar import declaration exists for the other target platforms as well. Take a look at the files at %ProgramFiles32%\MSBuild\Microsoft.Cpp\v4.0\Platforms\ for the specific names.
With this technique if you want a file to be imported then simply create a file that ends with .targets and place it into the appropriate folder. The advantage of this is that it will be imported into every VC++ build for that platform, and that you can create many different files. The drawback is that you have to place them in those specific folders. That's the main difference between both techniques. With this first technique you can specify the file location via property and its not automatically included for every build, but for the second approach it is but you cannot change the location
You can also add project content into one of *.props files from directory %LOCALAPPDATA%\Microsoft\MSBuild\v4.0\
It make same effect.