I've done some research online and turned up with results that did not sit well with me. I’m using the System.Xml.XslC ompiledTransfor m class as recommended by MS; however, it’s creating self-closing tags that I don’t want, example:
* My XSLT has: [HTML]<script language="javas cript" src="client_scr ipts/VehInInv.js"></script> [/HTML]
* Using the XslCompiledTran sform class I get: [HTML]<script language="javas cript" src="client_scr ipts/VehInInv.js"/>[/HTML] -- notice the missing[HTML] </script> [/HTML] tag
This is not well formed HTML and results in a blank looking page even though a view source of the page I can the rest of the HTML. Is there a way around this through the Transformer MS is telling me to use? Some solutions on the web are to go through each XSLT and replace with empty space in my stylesheet, example:
[HTML]<script language="javas cript" src="client_scr ipts/VehInInv.js"><x sl:text disable-output-escaping="yes"> &nbsp;</xsl:text></script>[/HTML]
However, with 60+ stylesheets and the understanding that I could still run into other issues (i.e. using <div></div> or some other empty tag that maybe I’m placing out there to be later manipulated through javascript) I don’t like the idea of this. The transformation function I wrote is below:
Public Function fnTransformXML_ new() As String
Dim log As clsLog4Net = Nothing
Dim oParm As clsTransformerP arms = Nothing
Dim xslt As XslCompiledTran sform
Dim xsltArgList As XsltArgumentLis t
Dim xDoc As XPathDocument
Dim writer As XmlWriter
Dim reader As XmlReader
Dim stWrite As StringWriter
log = New clsLog4Net
oParm = New clsTransformerP arms
xslt = New XslCompiledTran sform
xsltArgList = New XsltArgumentLis t
stWrite = New StringWriter
Dim xsltsettings As XsltSettings = New XsltSettings
xslt.Load(XSL_P ath, xsltsettings, New XmlUrlResolver( ))
Dim xmlsettings As XmlReaderSettin gs = New XmlReaderSettin gs
xmlsettings.Con formanceLevel = ConformanceLeve l.Fragment
xmlsettings.Ign oreWhitespace = True
reader = XmlReader.Creat e(New StringReader(XM L_String), xmlsettings)
For Each oParm In mCol
If Not IsNothing(oParm ) Then
If IsNothing(oParm .ParmValue) Then
xsltArgList.Add Param(oParm.Par mName.ToString, "", "")
Else
xsltArgList.Add Param(oParm.Par mName.ToString, "", oParm.ParmValue .ToString)
End If
End If
Next oParm
writer = New XmlTextWriter(s tWrite)
xslt.Transform( reader, xsltArgList, writer)
fnTransformXML_ new = stWrite.ToStrin g
End Function
Is there a property of the transformer class that I can turn off/on? Please help.
1 8026 this is a small class i use to solve the problem
Public Class XHTMLWriter : Inherits XmlTextWriter
Public EmptyElements() As String = New String() {"area", "base", "basefont", "br", "col", "frame", "hr", "img", "input", _
"isindex", "link", "meta", "param"}
Private ElementStack As New System.Collecti ons.Stack
Public Sub New(ByVal w As System.IO.Strea m, ByVal encoding As System.Text.Enc oding)
MyBase.New(w, encoding)
End Sub
Public Overloads Overrides Sub WriteEndElement ()
Dim localName As String = CStr(ElementSta ck.Pop)
If System.Array.In dexOf(EmptyElem ents, localName) <> -1 Then
MyBase.WriteEnd Element()
Else
MyBase.WriteFul lEndElement()
End If
End Sub
Public Overloads Overrides Sub WriteStartEleme nt(ByVal prefix As String, ByVal localName As String, ByVal ns As String)
Me.ElementStack .Push(localName )
MyBase.WriteSta rtElement(prefi x, localName, ns)
End Sub
End Class usage:
Public Shared Function myTransform(ByV al xslPath As String, ByVal xDoc As IXPathNavigable , ByRef output As Stream) As Boolean
Dim xslt As XslCompiledTran sform = Nothing
With HttpContext.Cur rent
xslPath = .Server.MapPath (xslPath)
If .Cache.Item(xsl Path) Is Nothing Then
xslt = New XslCompiledTran sform()
xslt.Load(xslPa th)
' if the file xslPath is modified the cache will be expired
' warning ! if any include template is modified, the cached object won't be changed
.Cache.Insert(x slPath, xslt, New CacheDependency (xslPath))
Else
xslt = .Cache(xslPath)
End If
End With
Dim ws As XmlWriterSettin gs = xslt.OutputSett ings.Clone()
Dim xw As New XHTMLWriter(out put, ws.Encoding)
xw.Formatting = Formatting.Inde nted
xslt.Transform( xDoc, xw)
Return True
End Function problems:
- <xsl: output ... has no effect
- you must inlude manually doctype in template
<xsl:text disable-output-escaping="yes"> <![CDATA[ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/Strict.dtd"> ]]></xsl:text>
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: phil_nospam_schmidt |
last post by:
I am trying to prevent a user from resizing a frame beyond its
"natural" size as given by winfo_reqwidth and winfo_reqheight, without
any success. Can anyone make any suggestions, based on my code below?
Thanks!
from Tkinter import *
class Table(Frame):
def __init__(self, master,
|
by: Eugen Gulinsky |
last post by:
Hello guys,
I am having problems trying to migrate our MSXML4-compatible stylesheets
containing large msxsl:script blocks to a formate understandable by
System.Xml:Xsl.XslTransform. I keep getting JS1135 errors saying that some
variable was not declared. This scripts worked perfectly with MSXML4. Is
there a guide for migraiton from MSXML to .NET or can you just give me some
tips on how to resolve this issues without having to change...
|
by: Eckhard Schwabe |
last post by:
when switching from the old "XslTransform " to "XslCompiledTransform"
I notice a difference in the handling of whitespace. I need to transform
a XML file which contain tabs (\t), and which remain untouched when I
use XslTransform to do the transformation.
But after switching to XslCompiledTransform the tabs are transformed to
a single space in the result file, which leads to problems later on the
the program.
what I found was:...
|
by: Daniel |
last post by:
Does system.xml have any way to transofrm data with an xswl style sheet
using strings like MSXML2 does?
how to convert this to use System.XML so i do not depend on MSXML2 interop?
static public string XslTransform(string style, string strdata)
{
MSXML2.IXMLDOMDocument pDoc = new MSXML2.DOMDocumentClass();
pDoc.async = false;
pDoc.loadXML(strdata);
|
by: W. Jordan |
last post by:
Hello there,
Are there anybody who is using the XslCompiledTransform that comes
with .net framework, which was said to be a replacement of the
XslTransform class?
I found that the class has some issues when the xsl file contains scripts.
The XslCompiledTransform uses the CodeDom to compile the scripts
within the xsl file into .net assembly and load them into the current
| |
by: Hans Kesting |
last post by:
Hi,
In our ASP.Net webapplications, we use xslt a lot. For 1.1 developing was
"easy":
start up the website and go to the page where the xslt was used. Change the
xslt
(save it) and refresh the page: the new results are visible.
Now we are transferring to 2.0 and XslCompiledTransform. The xslt's still
work
|
by: Mark |
last post by:
I'm getting the error "The URI scheme is too long." in the code below. What
is URI in this context? The XSL or the XML being transformed?
Thanks!
-Mark
StringBuilder sb = new StringBuilder();
//Create the XslCompiledTransform and Load it with the xsltDocument
XslCompiledTransform xslCompiledTransform = new XslCompiledTransform();
|
by: Andy Fish |
last post by:
Hi,
From reading the documentation, I get the impression that
XslCompiledTransform should be faster than XslTransform
on my test with a large complex document and a large complex XSLT, the
transform took 4 minutes with XslTransform but 7 minutes with
XslCompiledTransform.
However, with the same stylesheet on another large complex document, the
|
by: =?Utf-8?B?Um9iZXJ0?= |
last post by:
Hello all,
I have an XmlException being thrown trying to use XslCompiledTransform while
using the google api. My suspicion is there is some html decoding happening
that I want to prevent...
something like this
being changed into this
|
by: =?Utf-8?B?d2VqaXY=?= |
last post by:
When I use xslCompiledTransform() or xslCompiledTransform(false) I find that
the XPath queries in my select query attributes do not recognize any
attributes inthe xml document. But when I enable debugging
-xslCompiledTransform(true)- everything works as it should.
for example:
<Root>
<test attr1="avalue" />
<test attr1="anothervalue" />
</Root>
doing a
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |