473,789 Members | 2,388 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Empty element match

i have the following rule,
<xsl:template match="br">
<br/>
</xsl:template>
This should convert all <br/> to <br/>
but, my transformer transforms it all to
<br></br>
Ok this does not look like a problem but i use it in a
web application and microsoft interpretes this
as 2 <br/><br/>

How can i force the transformer to not use the
implicit end tag like this <br/> ?
Jul 20 '05
18 2435
Ok i will try to set the response mime type to text/xml, ok (or application/xml is probably better) is text/xhtml also possible?

no, the declared type for xhtml is text/xhtml+xml but IE doesn't know
about that.

You will need to use <?xml-stylesheet to specify a stylesheet (which can
simply be <xsl:copy-of select="."/>

But if you need to send to IE, why not send HTML, which it understands,
rather than XHTML, which it doesn't?

David
Jul 20 '05 #11
David Carlisle <da****@nag.co. uk> wrote:
no, the declared type for xhtml is text/xhtml+xml


ITYM application/xhtml+xml :-)

--
David Håsäther
Jul 20 '05 #12
ITYM application/xhtml+xml :-)


er yes, thanks.

Jul 20 '05 #13

but why how do i overcome the problem that the parser/transformer
on the hostingprovider does not listen to the xsl:output method attribute?
You need to tell your serialser to output using html.
You haven't said which system you are using. The onlt one I use that
doesn't use xsl:output is cocoon where the serialisers (be it html,
xhtml, text, pdf, ...) are set up in sitemap.xmap with lines looking
something like

<map:serializer s default="html">
<map:serializ er logger="sitemap .serializer.lin ks" name="links" src="org.apache .cocoon.seriali zation.LinkSeri alizer"/>

<map:serializ er logger="sitemap .serializer.xml " mime-type="applicati on/xml" name="xml" src="org.apache .cocoon.seriali zation.XMLSeria lizer"/>

<map:serializ er logger="sitemap .serializer.htm l" mime-type="text/html" name="html" pool-grow="4" pool-max="32" pool-min="4" src="org.apache .cocoon.seriali zation.HTMLSeri alizer">
<buffer-size>1024</buffer-size>
</map:serializer>

the above is just boiler plate declarations part of the default
site map

then for a particular file that is to be serialised as html:

<map:pipeline >
<map:match pattern="index. html">
<map:generate src="xml/frontpage.xml" type="file"/>
<map:transfor m src="stylesheet s/html/om-page.xsl"/>
<map:serializ e type="html"/>
^^^^^^^^^^^^^^^ ^
</map:match>
</map:pipeline>
If you are not using cocoon then the above syntax will be wrong, but
probably something similar is available...
David

Jul 20 '05 #14
David Carlisle wrote:
but why how do i overcome the problem that the parser/transformer


The hosting provider is running:

xsl
XSL enabled
libxslt Version 1.1.12
libxslt compiled against libxml Version 2.6.16
EXSLT enabled
libexslt Version 1.1.12

so libxslt 1.1.12.

With sablotron (i'm using that) there is no problem.
But what im doing is:

data.xml + form.xsl(output =xml) -> temp.xml (contains html tags but in
xml format)
temp.xml + page.xsl(output =html) -> page.html

In page.xsl there is a rule like this:

<!--
! All html should remain html
!-->
<xsl:template match="*[namespace-uri(.)='' or
namespace-uri(.)='http://www.w3.org/1999/xhtml']">
<xsl:copy>
<xsl:for-each select="@*">
<xsl:copy/>
</xsl:for-each>
<xsl:apply-templates select="./node()"/>
</xsl:copy>
</xsl:template>
Maybe this rule forces <br/> to convert to <br></br>
????
Jul 20 '05 #15


Tjerk Wolterink wrote:

In page.xsl there is a rule like this:

<!--
! All html should remain html
!-->
<xsl:template match="*[namespace-uri(.)='' or
namespace-uri(.)='http://www.w3.org/1999/xhtml']">
<xsl:copy>
<xsl:for-each select="@*">
<xsl:copy/>
</xsl:for-each>
<xsl:apply-templates select="./node()"/>
</xsl:copy>
</xsl:template>
Maybe this rule forces <br/> to convert to <br></br>


If you really want HTML output then you should strip the namespace from
XHTML elements e.g.
<xsl:template match="xhtml:*" >
xmlns:xhtml="ht tp://www.w3.org/1999/xhtml">
<xsl:element name="{local-name()}">
<xsl:copy-of select="@*" />
<xsl:apply-templates />
</xsl:element>
</xsl:template>

--

Martin Honnen
http://JavaScript.FAQTs.com/
Jul 20 '05 #16
Martin Honnen wrote:


Tjerk Wolterink wrote:

In page.xsl there is a rule like this:

<!--
! All html should remain html
!-->
<xsl:template match="*[namespace-uri(.)='' or
namespace-uri(.)='http://www.w3.org/1999/xhtml']">
<xsl:copy>
<xsl:for-each select="@*">
<xsl:copy/>
</xsl:for-each>
<xsl:apply-templates select="./node()"/>
</xsl:copy>
</xsl:template>
Maybe this rule forces <br/> to convert to <br></br>

If you really want HTML output then you should strip the namespace from
XHTML elements e.g.
<xsl:template match="xhtml:*" >
xmlns:xhtml="ht tp://www.w3.org/1999/xhtml">
<xsl:element name="{local-name()}">
<xsl:copy-of select="@*" />
<xsl:apply-templates />
</xsl:element>
</xsl:template>


Ok thus namespaces are not allowed in html?

I cannot wait until browser truely support xml syntax.

Another question,

How does xsl handle empty elements,
does it convert them to
<element/>
or to
<element></element>

And are there any settings in the parser to control that?
Jul 20 '05 #17
In article <da**********@n etlx020.civ.utw ente.nl>,
Tjerk Wolterink <tj***@wolterin kwebdesign.com> wrote:
Ok thus namespaces are not allowed in html?
HTML, being SGML rather than XML, knows nothing about namespaces.
As far as HTML is concerned, xhtml:html is an element it's never
heard of, and <html xmlns="whatever-the-xhtml-namespace-is"> has
an invalid attribute (though it probably wouldn't mind that).

But as far as outputting HTML from XSLT goes, only elements in no
namespace are output according to the HTML rules. So you have to
choose between outputting XHTML using the appropriate namespace, or
outputtting HTML with no namespace.
How does xsl handle empty elements,
does it convert them to
<element/>
or to
<element></element>


When outputting XML, it's up to the implementation, because they are
equivalent as XML. When outputting HTML, it will do the Right Thing,
according to what kind of HTML element it is (so it will output
always-empty elements as, for example, <br>).

-- Richard
Jul 20 '05 #18
Richard Tobin wrote:
In article <da**********@n etlx020.civ.utw ente.nl>,
Tjerk Wolterink <tj***@wolterin kwebdesign.com> wrote:

Ok thus namespaces are not allowed in html?

HTML, being SGML rather than XML, knows nothing about namespaces.
As far as HTML is concerned, xhtml:html is an element it's never
heard of, and <html xmlns="whatever-the-xhtml-namespace-is"> has
an invalid attribute (though it probably wouldn't mind that).

But as far as outputting HTML from XSLT goes, only elements in no
namespace are output according to the HTML rules. So you have to
choose between outputting XHTML using the appropriate namespace, or
outputtting HTML with no namespace.


ok but my output method is set to html, why are the namespaces still
there?
How does xsl handle empty elements,
does it convert them to
<element/>
or to
<element></element>

When outputting XML, it's up to the implementation, because they are
equivalent as XML. When outputting HTML, it will do the Right Thing,
according to what kind of HTML element it is (so it will output
always-empty elements as, for example, <br>).

-- Richard


ok thanks
Jul 20 '05 #19

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

Similar topics

13
3405
by: Mikko Ohtamaa | last post by:
From XML specification: The representation of an empty element is either a start-tag immediately followed by an end-tag, or an empty-element tag. (This means that <foo></foo> is equal to <foo/>) From XHTML specification:
2
1647
by: Victor | last post by:
While debugging my stylesheet using XMLSpy, I got a really weird result: <xsl:if test="$match = true()"> matches even if $match is an empty node fragment. How can this be? -- Victor
9
2241
by: Tjerk Wolterink | last post by:
I have an xsl file wich xsl:includes this file: <?xml version="1.0" encoding="ISO-8859-1"?> <xsl:stylesheet version="1.0" xmlns="http://www.w3.org/1999/xhtml" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:page="http://www.wolterinkwebdesign.com/xml/page" xmlns:xc="http://www.wolterinkwebdesign.com/xml/xcontent"> <xsl:output method="xml" indent="yes"/>
4
62500
by: n_o_s_p_a__m | last post by:
My xml doc has many <title></title> and <title> in it, meaning the nodes have no content (although some do). How can I test for this? I tried title (doesn't work) I tried //title (doesn't work) I tried //title (doesn't work) I tried //title (doesn't work) Any suggestions welcome.
3
1442
by: Jyrki Keisala | last post by:
I have an XML file which looks like this: <command name="Options" phrase="Options"> <key value="z" extended="NONE" qual="L-CTRL" pause="100" repeat="1" duration="200"/> </command> <command name="Command Room" phrase="Command Room"> <key extended="F2" pause="100" repeat="1" duration="200"/> </command>
2
1723
by: | last post by:
Okay, this is probably a really stupid question - but I just can't figure it out. I have a large xml document which is being transformed into another using ..net xsl - some elements inside of which do not have any data at some times but do at others. If they don't have any data, I want to suppress the generation of the tag completely in the resulting xml. So for example, if I have a document:
8
3707
by: darrel | last post by:
I have a when statement: <xsl:when test="//pageTitle = not(string(.))"> This should find the 'pageTitle' node that has a sibling of 'linkID' that matches the '$activeLink' parameter and see if it is empty or not. The above returns FALSE However, this:
3
2058
by: tschwartz | last post by:
I'm trying to write a stylesheet which removes nodes which are empty as a result of other template processing. For example, given the following xml, I'd like to: - remove all "b" elements - remove all "a" elements which, as a result of "b" element removal, now have no children so, starting with:
3
1002
by: Valery | last post by:
In the following XML: <?xml version="1.0" encoding="utf-8" ?> <Plcy service="ILiability" boId ="LifePolicy, 1"> <Prem service="IPremium" boId ="RegularPremium, 1"></Prem> <L1 service="ILifeMain" type = "Life1"> <FirstName>Sheila</FirstName> <Age>65</Age> <Relation>spouse</Relation> </L1>
0
9663
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
10404
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10136
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,...
0
9016
agi2029
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...
1
7525
isladogs
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...
0
5415
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
5548
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4089
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
3
2906
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.