473,791 Members | 3,360 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

System.Xml.Xsl. Transform -vs- xhtml???

I'm trying to output valid xhtml 1.0 transitional with xslt -- my question
is when dealing with elements that have self-closing tags such as <img />
and <input />...

I'm getting closing tags on these elements that should have a self-closing
tag like this:
<img src="/images/img.jpg" alt="alt text"></img>
should be:
<img src="/images/img.jpg" alt="alt text" />

Is this something wrong with my xsl? or is this an issue with the
System.Xml.Xsl. Transform method???

here's an example:
<xsl:element name="img">
<xsl:attribut e name="src"><xsl :value-of select="$folder "
/>/ui/img/<xsl:value-of select="Root/Portal/global/company_logo/@src"
/></xsl:attribute>
<xsl:attribut e name="alt"><xsl :value-of
select="Root/Portal/global/company_logo/@alt" /></xsl:attribute>
</xsl:element>

the output result is:
<img src="/test/ui/img/logo.png" alt="Logo Image"></img>

I've tried various settings in the xsl:output as well, here is the current:
<xsl:output method="xml" media-type="text/html" omit-xml-declaration="ye s"
doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN"
doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dt d"
encoding="UTF-8" indent="yes" />
the complete xsl doc is at:
http://clients.humaniz.net/xsl/sitemain.xsl
thanks!!!
mo
Nov 12 '05 #1
3 2906
Hello!
here's an example:
<xsl:element name="img">
<xsl:attribut e name="src"><xsl :value-of select="$folder "
/>/ui/img/<xsl:value-of select="Root/Portal/global/company_logo/@src"
/></xsl:attribute>
<xsl:attribut e name="alt"><xsl :value-of
select="Root/Portal/global/company_logo/@alt" /></xsl:attribute>
</xsl:element>


Maybe it helps if you use the inline-Attribute-syntax:

<img src="{$folder}/ui/img/{Root/Portal/global/company_logo/@src}
alt="{Root/Portal/global/company_logo/@alt}" />

(Visual Studio may show you errors like '{ is not valid in NAMEs' - just
ignore that.)
--
Pascal Schmitt
Nov 12 '05 #2


Martin Olson wrote:
I'm trying to output valid xhtml 1.0 transitional with xslt -- my question
is when dealing with elements that have self-closing tags such as <img />
and <input />...

I'm getting closing tags on these elements that should have a self-closing
tag like this:
<img src="/images/img.jpg" alt="alt text"></img>
should be:
<img src="/images/img.jpg" alt="alt text" />


For XML
<img />
and
<img/>
and
<img></img>
are equivalent ways of marking up an empty element with the name 'img'.
Your problem is that you do not only want to create XHTML and parse it
with an XHTML parser where <img></img> is fine but you seem to want to
send XHTML to HTML browsers like IE as content type text/html where the
XHTML is not parsed by an XML parser but by the browsers tag soup parser
that implements SGML with error correction and not XML.
So the problem is not with your stylesheet or your XSLT processor but
rather with your approach, see
<http://www.w3.org/TR/xhtml1/#guidelines>
<http://www.hixie.ch/advocacy/xhtml>

As long as you want to serve text/html consider using the proper
document type for that namely HTML 4.01 and not XHTML 1.0.

If you insist on serving XHTML 1.0 as text/html then you have to ensure
that your XHTML is backwards compatible with HTML and XSLT 1.0 has no
tools to achieve that so you need a custom serializer for the result
tree of your XSLT transformation. One solution for that can be found here:
<http://schneegans.de/asp.net/xhtmltextwriter/>

--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
Nov 12 '05 #3
Thank you both very much for your help.

I'll be using the inline attribute syntax on this project.

The info at: http://www.w3.org/TR/xhtml1/#guidelines is very helpful and
thanks for giving me a clue!

thanks!
mo
"Martin Olson" <pl****@no-spam.thankyou> wrote in message
news:uq******** ******@TK2MSFTN GP14.phx.gbl...
I'm trying to output valid xhtml 1.0 transitional with xslt -- my question
is when dealing with elements that have self-closing tags such as <img />
and <input />...

I'm getting closing tags on these elements that should have a self-closing
tag like this:
<img src="/images/img.jpg" alt="alt text"></img>
should be:
<img src="/images/img.jpg" alt="alt text" />

Is this something wrong with my xsl? or is this an issue with the
System.Xml.Xsl. Transform method???

here's an example:
<xsl:element name="img">
<xsl:attribut e name="src"><xsl :value-of select="$folder "
/>/ui/img/<xsl:value-of select="Root/Portal/global/company_logo/@src"
/></xsl:attribute>
<xsl:attribut e name="alt"><xsl :value-of
select="Root/Portal/global/company_logo/@alt" /></xsl:attribute>
</xsl:element>

the output result is:
<img src="/test/ui/img/logo.png" alt="Logo Image"></img>

I've tried various settings in the xsl:output as well, here is the
current:
<xsl:output method="xml" media-type="text/html" omit-xml-declaration="ye s"
doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN"
doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dt d"
encoding="UTF-8" indent="yes" />
the complete xsl doc is at:
http://clients.humaniz.net/xsl/sitemain.xsl
thanks!!!
mo

Nov 12 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
11474
by: Trevor | last post by:
Also posted in general ASP.NET forum. System.IO.IOException: The filename, directory name, or volume label syntax is incorrect. I have hit a problem for which I can find no solutions. Has anyone any ideas? I am writing XML into a Memory STream and using a Transform to make
3
2271
by: Steve | last post by:
Is there any way of specifying the startMode when using the xslTransform class? We are updating code which used msxml to the system.xml classes but can find no way to specify the startMode. We use this so that we can specify different templates to be used by the same xml node. Know that we could use global params, but would rather not have to update all teh stylesheets and any code that uses msxml and the same stylesheets.
4
4825
by: schneider | last post by:
Anyone know if there is a way to dynamicly create a Xslt template/s and use them as an xml transform with-out use files for the Xslt? All the methods I see use files. I want to create a Xslt transform via code? Any examples would be great.
2
3722
by: KJS | last post by:
Hello, I'm receiving: 'System.Xml.Xsl.XsltException: Missing mandatory attribute 'version' After I try and run my transformation. I spent a good few days coming up with the appropriate (I think) methods, and overrides for this task. I have verified that the source XML and XSL will transform by means of using the MSXML command line parsing tool (previous version of MSXML though). Here is my code:
4
4617
by: Tim Bücker | last post by:
Hello. I want to set my coordinate-system-origin (0/ 0) to the bottom-left corner. How is that done in C# the best way? Thanks a lot in advance! Greetings, Tim.
1
1111
by: bor_kev | last post by:
Hi! I'd like to know how to transform (or convert) a System :: String to a std :: string under Visual Studio (C++) 2005 Beta. Sincerely, bor_kev *---------------------------------* Posted at: http://www.GroupSrv.com
1
1918
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);
4
8532
by: Dean Card | last post by:
Okay, so here is the situation. I have need to do some on-the-fly image creation. I have everything working great except for the last part of it, applying a perspective type transform to the image. The transform will take a rectangular 2D image and transform it to a 3D representation in 2D. Please see the link to see what I am trying to do: http://seanberry.com/transform.png I have PIL v1.15 installed which has a PERSPECTIVE...
6
4970
by: Vijai Kalyan | last post by:
Hello, I am trying to use std::transform to take in a collection of strings, transform them and insert the result into an output container. So, I wrote something like this: std::wstring doSomething (std::wstring const& str) { // do something to copy of str and return new value }
1
2927
by: Praveen | last post by:
Have a common function in Javascript which do transform for all .xsl's. XSL object is loaded like this. var xslobj=new ActiveXObject("MSXML2.FreeThreadedDOMDocument.4.0"); xslobj.async = false; xslobj.load(xslpath); Here inserting an 'xsl:import' node to the xsl before doing transform. This xsl contains some common templates which can be used across all xsl's. So no need of doing import of this specifically in all xsl's.
0
9669
marktang
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...
0
9517
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9997
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6776
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();...
0
5435
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...
0
5559
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4110
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
2
3718
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2916
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.