Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2006-06-23
7
Medium Priority
?
759 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
  • 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
Veeam Disaster Recovery in Microsoft Azure

Veeam PN for Microsoft Azure is a FREE solution designed to simplify and automate the setup of a DR site in Microsoft Azure using lightweight software-defined networking. It reduces the complexity of VPN deployments and is designed for businesses of ALL sizes.

 

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

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

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 Import and export files in WordPress. 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 : Click on Too…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.
Suggested Courses

876 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