It's probably easy in XSLT 2, but if you're using XSLT 1 like most of us who are relying on Microsoft tools, avoiding duplicated xsl code ist hard. Using a workaround pattern I've sometimes applied in such cases it would look like this: Contents References This is not nice, and can be further refined, but the only way I know to avoid duplicating the logic contained in the for-each statement. I don't have the patience right now to adjust the tabs and spaces which don't look right in the preview. And please be aware that I just copied and pasted it from some old stylesheets of mine and your fragments and have not tested it. There may be syntax errors, but I'm sure you get the gist. And if any one points out a better pattern, I'll add my thanks to yours.
Frank Horn
Posts
-
Generate missing XML -
Memory usage problemYou may want to try GC.WaitForPendingFinalizers() as well. It's a perfomance killer and not recommended in most situations, but it could be interesting to see if it changes the memory usage you see in task manager.
-
Changing the value of text box at run time in .net 2.0 windows applicationI guess you're setting the text from within the comport_DataReceived event handler, which the SerialProt object calls from another thread. Either you read up on threading, or you don't use the event but put a timer onto your form (or control) and poll the com port from the timer's Tick event.
-
How can I convert garbled filenames (Chinese) to the correct codepage?No, I have no support for Asiian languages installed. Anyway, if it's actually about encoding, did you try something like this:
string source = "ûÓÐÈË¿ÉÒÔ½ÐÄ㱦±´";
Encoding sourceEncoding = Encoding.Default;
byte[] bytes = sourceEncoding.GetBytes(source);Encoding targetEncoding = Encoding.GetEncoding("gb2312");
string target = targetEncoding.GetString(bytes); -
How can I convert garbled filenames (Chinese) to the correct codepage?That's interesting. I'm not sure what the problem is though. Just created a file named 没有人可以叫你宝贝.txt on a German XP (hope it doesn't mean anything nasty), and in Explorer it shows up as a sequence of squares. This looks like a system thing indeed, cause the file name is correct (as I can see when I drag it into Firefox, which shows 没有人可以叫你宝贝.txt in the address bar). Is this the phenomenon you mean, or do your files also have a different name? And if so, can you reproduce it?
-
How do you add a control to a usercontrol during design time? [modified]Found something: read up on the ParentControlDesigner class http://msdn.microsoft.com/en-us/library/system.windows.forms.design.parentcontroldesigner(VS.71).aspx
-
How do you add a control to a usercontrol during design time? [modified]I had that problem myself and I'm not sure what best to do. Maybe there is a trick we both don't know. If you don't have a user control, but a control derived from Panel, you can drop controls onto it at design time and they will be added. Also I think if you have a Panel on your user control, you can drop controls onto the Panel. So maybe you can just fill your user control with a Panel and go from there.
-
How do you hide parts of a usercontrol from the toolbar.I think you can give those controls you want to hide an attribute
[System.ComponentModel.ToolboxItem(false)]
-
My computer can't do basic arithmetic (or I'm doing something stupid)The compilers understands the right side expressions to be integers. You only get a decent result with
float aspectRatio = (float)1280 / (float)500;
-
Check if a DLL is registeredIf it isn't, Activator.CreateInstance will throw an exception when you try to create an instance of a class from the COM library. There can be other reasons for the exception of course, so if you want to make sure it's the dll not being registered, you can check whether the registry key HKEY_CLASSES_ROOT\FullClassName is there (FullClassName being the string you pass to Activator.CreateInstance).
-
64-bit Progress Bar Maximum?Why don't you set the maximum to 100 and set the integer percentage value when it has changed? Setting the value a billion times will slow down your application anyway, and users won't see a difference.
-
Tracing Invalidate calls (Windows Forms)Can't you trap the calls from the overriden OnPaint() method? Or by overriding OnInvalidated()?
-
Inheritance and constructorsbut how do I get it to call both? You don't, cause you can only have on base instance, so you can't call two constructors. You'll have to put the code from both base class constructors into two protected methods and call each from the respective base class constructor, and call both from the derived class constructor.
-
Absolute to Relative PathUnfortunatly .Net seems to have an ugly gap here. but others have had this problem before, and you may get an idea here: http://mrpmorris.blogspot.com/2007/05/convert-absolute-path-to-relative-path.html
-
XSL copy-of problem!In the article they suppress the id attributes with the help of a template which matches them but does nothing. I think you're looking for something like Haven't tried it out though; could be faulty, but I hope you get the idea.
-
XSL copy-of problem!Starting to feel sort of responsible for your project... I'm not sure what the problem is this time though. What's the overall goal of your transformation? Do you want to a) copy all the B and EM tags of some HTML to a self defined XML( or HTML) structure, or b) reproduce a complete HTML with all B and EM tags having a set of attributes which may be missing in the original? When a: what's your target structure? When b: probably a little recursion is called for. http://www.xmlplease.com/xsltidentity might be a good link to start with.
-
XSL value-of output problem!Have you tried copy-of instead of value-of?
-
Hide control inherited from a base form in a specific derived form, this at design-time !You could derive in 3 steps: Form1 without the 4 controls Form2 = Form1 + 4 controls type 1 Form3 = Form1 + 4 controls type 2 and 7 forms derived from Form2
-
Loading controls with a BackgroundWorkerSorry, I never did this and only vaguely remember having read about it. Anyway, why do you need to load a control in the background? Usually loading a control doesnt't take so long that another thread makes sense. If it's because of many data or a huge image, you could load those in a (non-UI) worker thread.
-
XSL Nesting Problem!You're welcome. In case you can read German or French, this is where I learnt it all: http://selfhtml.org/ I hardly ever use websites in my native language when it comes to software development cause anglophone sites are abundant and (when they have a forum) well populated, but this one is so good I took it on as my default HTML and XSL reference.