Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

XSL/XML/XHTML: Include XML content and write to XHTML

Posted on 2006-06-23
7
Medium Priority
?
758 Views
Last Modified: 2013-12-16
Hi Gertone,

we have the following XSL scriptlet:

<xsl:variable name="webDescription" select="/Root/Object/ExternalReferences/Keyword[Characteristic='ZPDB_WEBDESCRIPTION']/Value"/>
<xsl:variable name="webDescriptionParsed" select="translate($webDescription, '\', '/')"/>
<xsl:copy-of select="document($webDescriptionParsed)"/>

Basically, it will read an XML file from the file server and should include the HTML content to the XHTML output stream.

The XHTML from XSL engine is as follows:

...
              <html>      
                <p>bla bla</p>      
              </html>
...

The XHTML 1.0 Strict validator has a problem with html/xmlns missiong and <P> not allowed.

Is there a trick how the XML header should look like so that HTML will be displayed and validated or should the XML file be addressed with XPath - but how to apply the format tags then?!

Ciao

0
Comment
Question by:go4java
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
7 Comments
 
LVL 60

Expert Comment

by:Geert Bormans
ID: 16968512
Hi go4java,

likely you can just put the namespace declaration in your snippet already
like this
<html xmlns="http://www.w3.org/1999/xhtml"

in xhtml strict <p> cannot be a child of <html>
you need at least a body tag

change your snippert to this and try again
              <html xmlns="http://www.w3.org/1999/xhtml">
                <body>    
                <p>bla bla</p>
                </body>    
              </html>


Cheers!
0
 

Author Comment

by:go4java
ID: 16968652
The XML now looks like that:

<?xml version="1.0" encoding="ISO-8859-1"?>
<html xmlns="http://www.w3.org/1999/xhtml">
  <body>
     <p>...</p>
  </body>      
</html>

The HTML output is:

              <html>  
                <body>      
                  <p>...</p>  
                </body>
              </html>

...and if I run the XSL as mentioned above, the XHTML strict 1.0 returnes the following errors:

- xmlns missing
- html not allowed
- body not allowed


0
 
LVL 60

Expert Comment

by:Geert Bormans
ID: 16969827
go4java,
> <xsl:copy-of select="document($webDescriptionParsed)"/>

just a quick guess
did you try this?
<xsl:copy-of select="document($webDescriptionParsed)//html"/>
it might help you keep the namespace declaration
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:go4java
ID: 16981796
unfortunately not...
0
 

Author Comment

by:go4java
ID: 16981886
I've removed <html> and <body>  from the input XML and inserted only a <div>-tag as root.
The result by the XHTML strict validator is as follows:

<div xmlns="">
xmlns is not allowed!

xmlns has automatically been inserted?!

Ciao


0
 

Author Comment

by:go4java
ID: 16990231
Hi Gertone,
we're able to manage like that:

<?xml version="1.0" encoding="ISO-8859-1"?>
<div xmlns="http://www.w3.org/1999/xhtml">
      <p>...</p>
</div>

0
 
LVL 60

Accepted Solution

by:
Geert Bormans earned 2000 total points
ID: 16990336
sorry, missed your message yesterday

> xmlns has automatically been inserted?!

yes, since you did not give the xhtml namespace with the <div> element,
the XSLT assumes you want it in the NULL namespace, so it is switched off by xmlns=""
by adding the namespace in the <div> you remain in the same namespace and likely the namespace node is not copied

If this validates well, that means you already had a <html><body> in the output before copying in your snippet

If you want the HTML snippets to be valid documents on their own,
you can leave the <html> and <body> in the snippet
and have your copy like this
<xsl:copy-of select="document($webDescriptionParsed)//html/body/node()"/>
or in order not to fight with all the namespace declarations
<xsl:copy-of select="document($webDescriptionParsed)//*[local-name() = 'html']/*[local-name() = 'body']/node()"/>
The ability to validate snippets can come in handy if the snippets become complex

just a thought
cheers

Geert

0

Featured Post

Get free NFR key for Veeam Availability Suite 9.5

Veeam is happy to provide a free NFR license (1 year, 2 sockets) to all certified IT Pros. The license allows for the non-production use of Veeam Availability Suite v9.5 in your home lab, without any feature limitations. It works for both VMware and Hyper-V environments

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
Without even knowing it, most of us are using web applications on a daily basis.  In fact, Gmail and Yahoo email, Twitter, Facebook, and eBay are used by most of us daily—and they are web applications. We generally confuse these web applications to…
The purpose of this video is to demonstrate how to set up an RSS Feed on a WordPress Website. This will be demonstrated using a Windows 8 PC. Feedburner will be used for this demonstration. Go to your WordPress login page. This will look like the…
The purpose of this video is to demonstrate how to set up the permalinks on a WordPress Website. This will be demonstrated using a Windows 8 PC. Go to your WordPress login page. This will look like the following: mywebsite.com/wp-login.php : Go t…

722 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question