Solved

Allow simple html table in xsd

Posted on 2008-10-16
12
824 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
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 
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

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

Question has a verified solution.

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

Why do we like using grid based layouts in website design? Let's look at the live examples of websites and compare them to grid based WordPress themes.
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.
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…

822 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