I am trying to make use of the tag which is defined in natvis.xsd (The natvis schema file) in order to write C# or C++ code to visualize a type. I cannot find any documentation on this, so I'm not sure how it works. In particular I need to specify a GUID for the CustomVisualizer. What does this GUID map to? How do I export the class that is registered with this GUID? What interface do I need to implement? In short, how do I connect the GUID that I specify in the .natvis file to the code that formats the object?
The documentation for natvis does not mention the existence of the CustomVisualizer tag, but it's in the natvis schema file and shows up in autocomplete. I found that PyTools appears to implement natvis Custom Visualizers using this method, but it seems some of the code is hidden, and I'm unable to locate the source for the actual native visualizer using this method.
Here is an example natvis file I would like to make work:
<?xml version="1.0" encoding="utf-8" ?>
<AutoVisualizer xmlns="http://schemas.microsoft.com/vstudio/debugger/natvis/2010">
<Type Name="MyCustomVisualizer">
<CustomVisualizer VisualizerId="{387446F9-4B29-4EE7-A948-346BF6995603}"/>
</Type>
</AutoVisualizer>
And I'm asking specifically about how to write the C# and/or C++ code to make this work.
https://code.msdn.microsoft.com/Writing-graphical-debugger-a17e3d75
You want to use a UIVisualizer, instead of a CustomVisualizer. Although CustomVisualizer appears in the schema, there appears to be no documentation about it. With the UIVisualizer, you get the inspector window in the watch view, which will launch the visualizer. The usage of the GUIDs related to the UIVisualizer are also discussed in that link.
Figured this out. You can see source at https://github.com/chromium/vs-chromium
TL;DR - There's a ton of work involved, I probably did some things wrong, and it's not easy.
I don't how use CustomVisualizer, but maybe visualizer that use LegacyAddin can solve your problem https://stackoverflow.com/a/11545420/61505
Related
I've created an xml document with QDomDocument class. Now I want to add a link to a style-sheet. Is it possible with QDomDocument?
I couldn't identify a method for it in the documentation.
According to the API documentation it looks like document.insertBefore(document.createProcessingInstruction("xml-stylesheet", "type='text/xsl' href='sheet.xsl'"), document.documentElement()) should do.
I have a XML Document, like this:
<?xml version="1.0" encoding="UTF-8"?>
<items>
<item s_no="1">
<title>title_1</title>
<path>path1</path>
<desc>descriptoion1</desc>
</item>
<item s_no="2">
<title>title_2</title>
<path>path2</path>
<desc>descriptoion2</desc>
</item>
This is generated from QXmlStreamWriter in Qt. I want a function to add <item> tag with all elements like <title>, <path> etc. and I want a function to remove an item tag by identifying s_no attributes. All this should be done, without affecting any other content in the file.
I've searched a lot,I know there are similar questions, I've tried some code but it didn't worked. Are there any functions that do this, in QDomDocument?
When I have looked into doing this in the past, it hasn't really been a trivial thing.
QDomDocument and QDomNode
I think you should be able to do it with QDomDocument and QDomNode. Sometimes it is hard to see all the possible functions just on the main page for the documentation of the class, because it can get so much from the abstract classes it is derived from... clicking "lists of all members" shows a complete list.
http://doc.qt.io/qt-5/qdomdocument-members.html
Some calls that look promising include: childNodes elementById elementsByTagName createNode insertBefore insertAfter removeChild.
UPDATE: A working example that shows a straight forward way how to delete and insert nodes on a QDomDocument.
https://github.com/peteristhegreat/xml_insert_remove
Note, that when adding QDomNodes/QDomElements, etc, every element needs to be created on the document, otherwise it doesn't stay in scope when you leave a function.
QXmlStreamReader and QXmlStreamWriter
A few documents I've seen (a few years ago) said that they highly recommend using the QXmlStream* classes since they are better supported, or have been maintained more recently. I think it has some better error handling and doesn't have to load the whole document to be useful.
So as far as editing the document and resaving it, the most direct way that I know of is to read in everything, and store it as nested C++ classes and then write them out.
QJson Example (similar to QXmlStream*
There is a similar example with Json, that really shows off the power of subclassing a read and a write function into your model.
http://doc.qt.io/qt-5/qtcore-json-savegame-example.html
I think a similar approach could be done with the stream reader and writer class for XML.
Hope that helps.
I've created .ascx user control and I'm trying to find a way for including it into xslt rendering. How can I do this? I'm doing it for Sitecore. I thought maybe create a placeholder, but placeholders cannot be defined in renderings. I appreciate any help you can provide.
It's not possible to include ASCX file into xslt file because: XSLT transforms XML to HTML or to XML or to plain text but not to ASP.NET pages.
You can include xslt file into ascx but not ascx into xslt file. The best way is to change your xslt file into ascx file, and to include there with placeholders or directly .
I'd suggest to avoid using XSLT.
They seem pretty easy to use, but it's really hard to refactor the code.
Well, it's not possible to call user controls(.ascx) directly from XSLT files. However depending upon what you want to achieve, you can call .net methods, called XSLT extension methods, from XSLT file. For instance, you may need to write code similar to below to call custom .Net GetData() method.
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:customObject="urn:yourNamespace">
<new-data>
<xsl:value-of select="customObject:GetData()"/>
</new-data>
...
Of course the type needs to be registered before it can be used. Type registration can be done into web.config or dynamically by calling AddExtensionObjectMethod of XSLTArgumentList class.
Sitecore offers XSLT extension controls too and unlike extension methods, it isn't a .net feature. XSL extension controls are XML elements in XSL renderings that correspond to .NET classes. For example, the XSL extension control corresponds to the
Sitecore.Web.UI.XslControls.Text .NET class. It will be consumed something like this in XSLT file:
XSL extension controls are standalone elements in the XSL code.
To register a custom type, add following to element in web.config:
<extension mode="on" type="NamespaceName.ClassName, AssemblyName" namespace="http://www.w3.org/1999/XSL/Transform" singleInstance="true"/>
Reference: http://sdn.sitecore.net/upload/sitecore6/64/presentation_component_xsl_reference_sc62-64-a4.pdf
I'm working part of a project that needs to display a .xml file with .xsl files.
Here's part of the code:
FILE_PATH = "myxsl.xsl"
...
Label content = new Label("content",xmlContent);
content.setEscapeModelStrings(false);
content.add(new XsltTransformerBehavior(FILE_PATH));
add(content);
...
Currently the page works if I use only one .xsl file. However, because the .xsl files I need to deal with can be really long, they are separated into several components.
for example, I will have
mymain.xsl, head.xsl, tables.xsl
the mymain.xsl has inclusion of the other like this
<xsl:include href="head.xsl"/>
<xsl:include href="tables.xsl"/>
I tried to set FILE_PATH to mymain.xsl, but it didn't work. The program can find mymain.xsl but cannot compile the stylesheet because it cannot find head.xsl and tables.xsl
I've been searching for a long time but still have no clue how to do this. Really appreciate any help. Thanks in advance.
I looked at the documentation of XsltTransformerBehavior, and it looks like it doesn't expose the functionality to set a custom URI resolver (which is basically what you want to do).
However, in the case that no-one else has a better solution, I can propose a workaround: Write an XSLT that merges your XSLT files into one file. See here for an XSLT that does this. If you're using Maven as build system, you can do this automatically in the generate-resources phase using the transform goal of the Maven XML Plugin. You can then associate the XsltTransformerBehavior with the single-file XSLT which will be available at run-time.
My data coming from the database might contain some html. If I use
string dataFromDb = "Some text<br />some more <br><ul><li>item 1</li></ul>";
HttpContext.Current.Server.HtmlEncode(dateFromDb);
Then everything gets encoded and I see the safe Html on the screen.
However, I want to be able to execute the safe html as noted in the dataFromDb above.
I think I am trying to create white list to check against.
How do I go about doing this?
Is there some Regex already out there that can do this?
Check out this article the AntiXSS library is also worth a look
You should use the Microsoft AntiXSS library. I believe the latest version is available here. Specifically, you'll want to use the GetSafeHtmlFragment method.