Solved

Allow simple html table in xsd

Posted on 2008-10-16
12
837 Views
Last Modified: 2012-06-22
Hi,

I have an xsd written by someone else and used not only to validate in xml spy but also when running a maven build.

I now want to be able to enter a simple html table into the xml, but am not allowed.

Can you help me either by explaining how to enter the table in a section (there IS a Table item, but that is not an html table) OR help me add a table with rows and cells to the xsd? The cells will have bold, cursive, bold+cursive and bullets

Thanks a LOT
help.xsd.txt
0
Comment
Question by:Michel Plungjan
  • 6
  • 4
12 Comments
 
LVL 96

Expert Comment

by:Bob Learned
ID: 22757897
I would think that you need to create a CDATA element, so that the XML parser will ignore the HTML table.
0
 
LVL 28

Expert Comment

by:Pravin Asar
ID: 22759425
You can do following to get around the problem.

I am uploading sample xml and xsl

<!--- XML CODE -->

<?xml version="1.0" encoding="iso-8850-150"?>
<MYDATA>
    <TITLE>This is a News Title</TITLE>
    <HTMLDATA>
        <!--
        <BODY bgcolor=white><P>This contains malformed HTML<BR>
        <IMG SRC=http://www.evolt.org/images/logo.gif width=120 height=30>
        -->
    </HTMLDATA>
</MYDATA>

<!-- XSL CODE -->
 
<?xml version="1.0" encoding="iso-8850-150"?>
<xsl:stylesheet>
 
<xsl:template match="/">
      <xsl:value-of select="MYDATA/TITLE"/>
      <xsl:value-of select="MYDATA/HTMLDATA/comment()" disable-output-escaping="yes"/>
</xsl:template>
 
</xsl:stylesheet>

Open in new window

0
 
LVL 28

Expert Comment

by:Pravin Asar
ID: 22759679
This is a xsd file for html table
If you are using xml editor (such XMLSPY), you should be able generate a sample xml from this one.


<?xml version="1.0" encoding="UTF-8"?>
<!--W3C Schema generated by XMLSpy v2008 rel. 2 sp2 (http://www.altova.com)-->
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
      <xs:element name="TR">
            <xs:complexType>
                  <xs:sequence>
                        <xs:element ref="TD" maxOccurs="unbounded"/>
                  </xs:sequence>
            </xs:complexType>
      </xs:element>
      <xs:element name="TD" type="xs:string"/>
      <xs:element name="TABLE">
            <xs:complexType>
                  <xs:sequence>
                        <xs:element ref="TR" maxOccurs="unbounded"/>
                  </xs:sequence>
            </xs:complexType>
      </xs:element>
</xs:schema>

0
Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

 
LVL 75

Author Comment

by:Michel Plungjan
ID: 22764808
Excellent! I will try tomorrow

Do I need to define attributes if I want to have colspan and class for example?

Thanks!
0
 
LVL 28

Expert Comment

by:Pravin Asar
ID: 22767717
Here is xsd with colspan for TD and class, width for TR

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
      <xs:element name="TR">
            <xs:complexType>
                  <xs:sequence>
                        <xs:element ref="TD" maxOccurs="unbounded"/>
                  </xs:sequence>
                  <xs:attribute name="class" type="xs:string" use="optional" default="myclass"/>
                  <xs:attribute name="width" type="xs:string" use="optional" default="100%"/>
            </xs:complexType>
      </xs:element>
      <xs:element name="TD">
            <xs:complexType>
                  <xs:simpleContent>
                        <xs:extension base="xs:string">
                              <xs:attribute name="colspan" type="xs:int" use="optional" default="1"/>
                        </xs:extension>
                  </xs:simpleContent>
            </xs:complexType>
      </xs:element>
      <xs:element name="TABLE">
            <xs:complexType>
                  <xs:sequence>
                        <xs:element ref="TR" maxOccurs="unbounded"/>
                  </xs:sequence>
            </xs:complexType>
      </xs:element>
</xs:schema>
0
 
LVL 28

Expert Comment

by:Pravin Asar
ID: 22767725
Sample XML File


<?xml version="1.0" encoding="UTF-8"?>
<TABLE xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="C:\tmp\XML\myhtml.xsd">
      <TR class="myclass" width="100%">
            <TD>ROW 1 CELL 1</TD>
            <TD>ROW 1 CELL 2</TD>
      </TR>
      <TR class="class2" width="50%">
            <TD>ROW 2 CELL 1</TD>
            <TD>ROW 2 CELL 2</TD>
      </TR>
      <TR>
            <TD colspan="2">ROW 3 CELL 1</TD>
      </TR>
</TABLE>
0
 
LVL 75

Author Comment

by:Michel Plungjan
ID: 22767943
Thanks a lot.

Not as simple as 1,2,3 :|
0
 
LVL 75

Author Comment

by:Michel Plungjan
ID: 22834144
Hm.

Still have a hard time entering <b> and <i> in a cell :(((
0
 
LVL 28

Accepted Solution

by:
Pravin Asar earned 500 total points
ID: 22835769
See if you like this one.


<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
      <xs:element name="TR">
            <xs:complexType>
                  <xs:sequence>
                        <xs:element ref="TD" maxOccurs="unbounded"/>
                  </xs:sequence>
                  <xs:attribute name="class" type="xs:string" use="optional" default="myclass"/>
                  <xs:attribute name="width" type="xs:string" use="optional" default="100%"/>
            </xs:complexType>
      </xs:element>
      <xs:element name="TD">
            <xs:complexType>
                  <xs:sequence>
                        <xs:element ref="B"/>
                        <xs:element ref="I"/>
                  </xs:sequence>
                  <xs:attribute name="colspan" type="xs:string" use="optional" default="1"/>
                  <xs:attribute name="class" type="xs:string" use="optional" default="myclass"/>
                  <xs:attribute name="width" type="xs:string" use="optional" default="100%"/>
            </xs:complexType>
      </xs:element>
      <xs:element name="B">
            <xs:complexType>
                  <xs:sequence>
                        <xs:element ref="I"/>
                  </xs:sequence>
                  <xs:attribute name="weight" type="xs:string" use="optional" default="bold"/>
            </xs:complexType>
      </xs:element>
      <xs:element name="I">
      </xs:element>
      <xs:element name="TABLE">
            <xs:complexType>
                  <xs:sequence>
                        <xs:element ref="TR" maxOccurs="unbounded"/>
                  </xs:sequence>
            </xs:complexType>
      </xs:element>
</xs:schema>
0
 
LVL 28

Expert Comment

by:Pravin Asar
ID: 22835782
Here is a Sample XML

<?xml version="1.0" encoding="UTF-8"?>
<!--Sample XML file -->
<TABLE xsi:noNamespaceSchemaLocation="myhtml.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
      <TR width="100%" class="myclass">
            <TD colspan="1" width="100%" class="myclass">
                  <B weight="bold">
                        <I>text</I>
                  </B>
                  <I>text</I>
            </TD>
            <TD colspan="1" width="100%" class="myclass">
                  <B weight="bold">
                        <I>text</I>
                  </B>
                  <I>text</I>
            </TD>
      </TR>
      <TR width="100%" class="myclass">
            <TD colspan="1" width="100%" class="myclass">
                  <B weight="bold">
                        <I>text</I>
                  </B>
                  <I>text</I>
            </TD>
            <TD colspan="1" width="100%" class="myclass">
                  <B weight="bold">
                        <I>text</I>
                  </B>
                  <I>text</I>
            </TD>
      </TR>
</TABLE>
 
0
 
LVL 75

Author Closing Comment

by:Michel Plungjan
ID: 31506711
Thanks - I still need the table cell content to accept and but for now I close it
0

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

Color can increase conversions, create feelings of warmth or even incite people to get behind a cause. If you want your website to really impact site visitors, then it is vital to consider the impact color has on them.
When crafting your “Why Us” page, there are a plethora of pitfalls to avoid. Follow these five tips, and you’ll be well on your way to creating an effective page.
The viewer will get a basic understanding of what section 508 compliance can entail, learn about skip navigation links, alt text, transcripts, and font size controls.
The is a quite short video tutorial. In this video, I'm going to show you how to create self-host WordPress blog with free hosting service.

830 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