Solved

Allow simple html table in xsd

Posted on 2008-10-16
12
811 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
 
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
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 
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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Any business that wants to seriously grow needs to keep the needs and desires of an international audience of their websites in mind. Making a website friendly to international users isn’t prohibitively expensive and can provide an incredible return…
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

920 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now