cancel
Showing results for 
Search instead for 
Did you mean: 

Edit Web Content Wizard

mohanakannan_19
Champ in-the-making
Champ in-the-making
Hi,

      I have created a web form by using xsd, xsl and ftl. Iam trying to edit a web content and i got the following error in alfresco explorer.

      java.lang.IllegalArgumentException: instance document root tag name invalid. expected sample, got html
     
      The files are below:
sample.xsd

<?xml version="1.0"?>

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
           elementFormDefault="qualified">

  <xs:element name="sample">
    <xs:complexType>
      <xs:sequence>
        <xs:element name="name" type="xs:normalizedString"/>
        <xs:element name="city" type="xs:normalizedString"/>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
</xs:schema>


sample.xsl

<?xml version="1.0" encoding="utf-8" standalone="no" ?>
<xsl:stylesheet xmlns="http://www.w3.org/1999/xhtml" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xsl:version="1.0">
<xslSmiley Surprisedutput method="xml" encoding="utf-8" indent="yes" doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN" />
<xsl:template match="/">
<xsl:element name="html">
<xsl:element name="body">
<xsl:element name="table">
<xsl:attribute name="cellspacing">0</xsl:attribute>
<xsl:attribute name="cellpadding">0</xsl:attribute>
<xsl:attribute name="border">0</xsl:attribute>
<xsl:element name="tr">
<xsl:element name="th">
Name
</xsl:element>
<xsl:element name="th">
City
</xsl:element>
</xsl:element>
<xsl:element name="tr">
<xsl:element name="td">
Mohan
</xsl:element>
<xsl:element name="td">
Theni
</xsl:element>
</xsl:element>
<xsl:element name="tr">
<xsl:element name="td">
Dev
</xsl:element>
<xsl:element name="td">
Madurai
</xsl:element>
</xsl:element>
</xsl:element>
</xsl:element>
</xsl:element>
</xsl:template>
</xsl:stylesheet>


sample.ftl

<html>
<body>
<table cellspacing="0" cellpadding="0" border="0">
<tr><th>Name</th><th>City</th></tr>
<tr><td>${sample.name}</td><td>${sample.city}</td></tr>
<tr><td>${sample.name}</td><td>${sample.city}</td></tr>
</table>
</body>
</html>

anything wrong in my code. how to resolve this error.?
Thanks in advance..
1 REPLY 1

sujaypillai
Confirmed Champ
Confirmed Champ
Hi Mohan,

I do find <xslSmiley Surprisedutput method="xml" encoding="utf-8" indent="yes"….. line in your XSL file declaration and the code in it tries to create a new xml.

To let you know the xsd itself creates a xml file which in turn can be used to create the required output.

Check out with the below xsl :

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" >
<xsl:template match="/">
<html>
<head>Test Page</head>
<body>
<table cellspacing="0" cellpadding="0" border="0">
<tr><th>Name</th><th>City</th></tr>
<tr><td><xsl:value-of select="sample/name"/></td><td><xsl:value-of select="sample/city"/></td></tr>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>

If you are in need of multiple values for Name & City then you may need to change the xsd so that it has an element which is of type maxOccurs="unbounded" and using <xsl:for-each> tag you may iterate over all the items.

Hope so that helps you out.

Thanks,