Solved

Allow simple html table in xsd

Posted on 2008-10-16
12
800 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
What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

 
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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

I found this questions asking how to do this in many different forums, so I will describe here how to implement a solution using PHP and AJAX. The logical flow for the problem should be: Write an event handler for the first drop down box to get …
Many times as a report developer I've been asked to display normalized data such as three rows with values Jack, Joe, and Bob as a single comma-separated string such as 'Jack, Joe, Bob', and vice versa.  Here's how to do it. 
The viewer will learn how to dynamically set the form action using jQuery.
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…

760 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

19 Experts available now in Live!

Get 1:1 Help Now