W3C home > Mailing lists > Public > xmlschema-dev@w3.org > February 2002

Re: Formattings in XML Document!

From: G. Ken Holman <gkholman@CraneSoftwrights.com>
Date: Fri, 15 Feb 2002 10:39:18 -0500
Message-Id: <5.1.0.14.0.20020215102415.02444ff0@pop1.attglobal.net>
To: "Schema_Mailinglist" <xmlschema-dev@w3.org>
At 2002-02-15 15:56 +0100, mogot@web.de wrote:
>But I want to ask, how can I HTML-elements without defining these in my 
>primary schema?

By making the kurztext element unconstrained (deriving it directly from 
ur-type).  I changed your use of complexType to just be an empty element.

As for the stylesheet, you have redundantly declared template rules for 
HTML when you could just copy them from the source XML if you trust they 
contents are valid HTML.  But then the problem is the namespace nodes of 
your source end up in your result HTML.  Note below how I wrote a template 
that copies elements to the result while stripping namespace nodes attached 
to the elements in the source.

I hope this helps.

.................... Ken

T:\ftemp>type mogot.xsd
<?xml version="1.0" encoding="iso-8859-1"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" 
elementFormDefault="qualified">
         <xs:element name="kurztext"/>
         <xs:element name="root">
                 <xs:complexType>
                         <xs:sequence>
                                 <xs:element ref="kurztext" 
maxOccurs="unbounded"/>
                         </xs:sequence>
                 </xs:complexType>
         </xs:element>
</xs:schema>

T:\ftemp>type mogot.xml
<?xml version="1.0" encoding="iso-8859-1"?>
<root xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xsi:noNamespaceSchemaLocation="E:\formatierung_text\formatierung_text(1).xsd">
         <kurztext>
                         Dies ist ein Text mit
                         <b>fetten</b>
                         und hohen
                         <sup>2</sup>
                         Elementen E<sub>B</sub>.
         </kurztext>
         <kurztext>
                         Dies ist ein Text mit Objekt
                         <sub>fetten</sub>
                         und FlSche 12m
                         <sup>2</sup> und
                         <b>Elementen</b>
         </kurztext>
</root>

T:\ftemp>type mogot.xsl
<?xml version="1.0" encoding="iso-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" doctype-public="-//W3C//DTD HTML 4.0 
Transitional//EN"/>

<xsl:template match="root">
   <xsl:for-each select="kurztext">
     <p>
       <xsl:text/>Kurztext <xsl:value-of select="position()"/>: <xsl:text/>
     </p>
     <xsl:apply-templates mode="no-namespaces"/>
   </xsl:for-each>
</xsl:template>

<xsl:template match="*" mode="no-namespaces">
   <xsl:element name="{name(.)}">
     <xsl:copy-of select="@*"/>
     <xsl:apply-templates mode="no-namespaces"/>
   </xsl:element>
</xsl:template>

</xsl:stylesheet>

T:\ftemp>xt mogot.xml mogot.xsl
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<p>Kurztext 1: </p>
                         Dies ist ein Text mit
                         <b>fetten</b>
                         und hohen
                         <sup>2</sup>
                         Elementen E<sub>B</sub>.
         <p>Kurztext 2: </p>
                         Dies ist ein Text mit Objekt
                         <sub>fetten</sub>
                         und Fl&auml;che 12m
                         <sup>2</sup> und
                         <b>Elementen</b>


T:\ftemp>


--
Upcoming: 3-days XSLT/XPath and/or 2-days XSLFO - Feb 18-22, 2002

G. Ken Holman                mailto:gkholman@CraneSoftwrights.com
Crane Softwrights Ltd.         http://www.CraneSoftwrights.com/x/
Box 266, Kars, Ontario CANADA K0A-2E0 +1(613)489-0999 (Fax:-0995)
ISBN 0-13-065196-6                        Definitive XSLT & XPath
ISBN 1-894049-08-X  Practical Transformation Using XSLT and XPath
ISBN 1-894049-07-1               Practical Formatting Using XSLFO
XSL/XML/DSSSL/SGML/OmniMark services, books(electronic, printed),
articles, training(instructor-live,Internet-live,web/CD,licensed)
Next public training:         2002-02-18,21,27,03-04,05,06,11,15,
-              04-08,09,10,11,05-06,07,09,10,06-04,07,10,11,13,14
Received on Friday, 15 February 2002 10:39:57 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Tuesday, 11 January 2011 00:14:26 GMT