Solved

Allow simple html table in xsd

Posted on 2008-10-16
12
858 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 29

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 29

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
Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

 
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 29

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 29

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 29

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 29

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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

An enjoyable and seamless user experience can go a long way on an eCommerce site. While a cohesive layout and engaging copy play roles in creating a positive user experience, some sites neglect aspects that seem marginal but in actuality prove very …
This article will inform Clients about common and important expectations from the freelancers (Experts) who are looking at your Gig.
This tutorial demonstrates how to identify and create boundary or building outlines in Google Maps. In this example, I outline the boundaries of an enclosed skatepark within a community park.  Login to your Google Account, then  Google for "Google M…
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.

691 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