Link to home
Start Free TrialLog in
Avatar of go4java
go4java

asked on

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

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

Avatar of Gertone (Geert Bormans)
Gertone (Geert Bormans)
Flag of Belgium image

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!
Avatar of go4java
go4java

ASKER

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


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
Avatar of go4java

ASKER

unfortunately not...
Avatar of go4java

ASKER

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


Avatar of go4java

ASKER

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>

ASKER CERTIFIED SOLUTION
Avatar of Gertone (Geert Bormans)
Gertone (Geert Bormans)
Flag of Belgium image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial