cancel
Showing results for 
Search instead for 
Did you mean: 

include jsp in a xsd file

brek
Champ in-the-making
Champ in-the-making
Hi!
I have a problem including a jsp in a xsd file.
My xsd file is this:
<?xml version="1.0"?>

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
      xmlnsSmiley Tonguer="http://www.alfresco.org/alfresco/pr"
           targetNamespace="http://www.alfresco.org/alfresco/pr"
           xmlns:alf="http://www.alfresco.org"
           elementFormDefault="qualified">

  <!– dynamically loads the company footer choices simple type –>
  <xs:include schemaLocation="/get_company_footer_choices_simple_type.jsp"/>

  <xs:simpleType name="category">
    <xs:restriction base="xs:normalizedString">
      <xs:enumeration value="Product"/>
      <xs:enumeration value="Partnership"/>
      <xs:enumeration value="Company"/>
      <xs:enumeration value="Event"/>
      <xs:enumeration value="Training"/>
    </xs:restriction>
  </xs:simpleType>

  <!– defines the form for creating a press release –>
  <xs:element name="press_release">
    <xs:complexType>
      <xs:sequence>
        <xs:element name="title" type="xs:normalizedString"/>
        <xs:element name="abstract" type="xs:string"><xs:annotation><xs:appinfo><alf:appearance>full</alf:appearance></xs:appinfo></xs:annotation></xs:element>
       
        <xs:element name="body" type="xs:string" minOccurs="1" maxOccurs="unbounded"> <xs:annotation><xs:appinfo><alf:appearance>full</alf:appearance></xs:appinfo></xs:annotation></xs:element>
   <xs:element name="include_company_footer" type="pr:company_footer_choices" minOccurs="1" maxOccurs="unbounded"/>
   <xs:element name="include_in_home" type="xs:boolean" default="true"/>
   <xs:element name="picture" type="xs:anyURI" minOccurs="0" maxOccurs="unbounded"/>
   <xs:element name="category" type="pr:category" default="Company"/>
   <xs:element name="launch_date" type="xs:date"/>
   
      </xs:sequence>
    </xs:complexType>
  </xs:element>
</xs:schema>

instead, my jsp is:

<jsp:root version="1.2"
          xmlns:jsp="http://java.sun.com/JSP/Page"
     xmlns:c="http://java.sun.com/jsp/jstl/core"
     xmlnsSmiley Tonguer="http://www.alfresco.org/alfresco/pr">  
  <!– xmlnsSmiley Tonguer is mapped to /WEB-INF/pr.tld by web.xml –>
  <jsp:directive.page language="java" contentType="text/html; charset=UTF-8"/>
  <jsp:directive.page isELIgnored="false"/>

  <!–  The expected output is in the form:–>
 
  <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
             xmlns:alf="http://www.alfresco.org/alfresco"
        elementFormDefault="qualified">
       
    <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
                            xmlns:alf="http://www.alfresco.org"
                             elementFormDefault="qualified">
   
                  <xs:simpleType name="company_footer_choices">
                     <xs:restriction base="xs:normalizedString">
                  <!– call into CompanyFooterBean to retrieve all company footers –>
                    <c:forEach items="${pr:getCompanyFooterChoices(pageContext)}" var="companyFooter">
                         <jsp:element name="xs:enumeration">
                               <!– this is the file name of the company footer –>
                               <jsp:attribute name="value"><cSmiley Surprisedut value="${companyFooter.fileName}"/></jsp:attribute>
                                 <jsp:body>
                                   <xs:annotation>
                                         <xs:appinfo>
        <!– this produces the label displayed in the combobox within the press release form –>
                  <alf:label><cSmiley Surprisedut value="${companyFooter.name}"/></alf:label>
      </xs:appinfo>
              </xs:annotation>
            </jsp:body>
     </jsp:element>
        </c:forEach>
      </xs:restriction>
    </xs:simpleType>
  </xs:schema>

When i try to create a content using the xsd file i have this error:

org.alfresco.web.forms.FormProcessor$ProcessingException: org.alfresco.web.forms.xforms.FormBuilderException: error parsing schema: at line 54 column 114: src-resolve: Cannot resolve the name 'pr:company_footer_choices' to a(n) 'type definition' component.

but if i use this jsp:

<jsp:root version="1.2"
          xmlns:jsp="http://java.sun.com/JSP/Page"
         xmlns:c="http://java.sun.com/jsp/jstl/core"
         xmlnsSmiley Tonguer="http://www.alfresco.org/alfresco/pr">  
 
         <!– xmlnsSmiley Tonguer is mapped to /WEB-INF/pr.tld by web.xml –>
         <jsp:directive.page language="java" contentType="text/html; charset=UTF-8"/>
        <jsp:directive.page isELIgnored="false"/>

    
         <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
                            xmlns:alfresco="http://www.alfresco.org"
                             elementFormDefault="qualified">
   
                <xs:simpleType name="company_footer_choices">
      <xs:restriction base="xs:string">
        <xs:enumeration value="company_footer_1.xml">
     <xs:annotation>
       <xs:appinfo>
         <alfresco:label>Company Footer 1 Name</alfresco:label>
       </xs:appinfo>
     </xs:annotation>
        </xs:enumeration>
        <xs:enumeration value="company_footer_2.xml">
     <xs:annotation>
       <xs:appinfo>
         <alfresco:label>Company Footer 2 Name</alfresco:label>
       </xs:appinfo>
     </xs:annotation>
        </xs:enumeration>
      </xs:restriction>
    </xs:simpleType>
  </xs:schema>
</jsp:root>

all does it work.

My final scope is including a web form in another web form for create a dynamic field in a web form.

Can someone help me?

Thanks in advance

brek
7 REPLIES 7

jottley
Confirmed Champ
Confirmed Champ
Try previewing the jsp page.  Make sure that the returned page (view the source) is well-formed.  I have seen this issue when an xsd included jsp returned the doctype (<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">).  Once I removed that, the include worked.

As a side question, are you running Alfresco on Linux or Windows?

brek
Champ in-the-making
Champ in-the-making
thanks!
I try previewing jsp page and I have found the mistake. Now all works!

I run Alfresco on Windows XP

iapilgrim
Champ in-the-making
Champ in-the-making
Huhm…I don't think so. I got that error too. If I start the virtual tomcat, I can create web content but If I stop the virtual tomcat. I got it again. So what is the bug?

kvc
Champ in-the-making
Champ in-the-making
The dynamic includes (you can also just include a stock XSD.  JSP is useful for those cases where you do not want to prefix things like choice in an enumerated list) are executed by the Virtualization Server.  If you have an included JSP, but your Virtualization Server is not running, the include will not work.

Kevin

stevewickii
Champ in-the-making
Champ in-the-making
Is there a way to do this with a Web Script, instead of a JSP, and without WCM?  I want to create a simpleType with a dynamic list of enumeration elements based upon content in a Space in alfresco.

I created the webscript, and verified that the url /alfresco/s/test/ItemEnumType.xsd returns a valid XSD for a simpleType.  I added an xsd:include to my Data Dictionary/Forms/Example.xsd.  It was working before, with a static simpleType enumeration, but now it throws this error when I try to create content with the Example form: AVMNotFoundException: Store not found.

pmonks
Star Contributor
Star Contributor
I don't believe includes / imports can be used from DM forms yet, although there is an enhancement request to change the inclusion mechanism from JSPs to Web Scripts (which would allow this, amongst other things).

This enhancement request can be found at http://issues.alfresco.com/jira/browse/ETWOTWO-77 - I'd encourage you to vote and/or comment on it to ensure it gets prioritised appropriately.

Cheers,
Peter

zmicer
Champ in-the-making
Champ in-the-making
Alfresco Develers Guide (and my logic) states that dunamic includes would work:
- in the case the jsp is a part of your project content
- virtualization server is running, as JSP should be invoked in some context.

Be noticed seems to be this issue is not related to the issue with rendering stated here http://forums.alfresco.com/en/viewtopic.php?f=30&t=15778

I have reproduced this issue - even when virtualization server was running I had this problem. A fix is the same as pointed here http://forums.alfresco.com/en/viewtopic.php?f=30&t=7467, but applied at another place. See below the usage of AVMUtil.getStoreName(cwdAvmPath)

/web-client-sdk/source/java/org/alfresco/web/forms/xforms/XFormsBean.java, line 591
            final String baseURI = (uri.charAt(0) == '/'
                                    ? AVMUtil.buildStoreUrl(AVMUtil.getStoreName(cwdAvmPath))
                                    : AVMUtil.buildAssetUrl(cwdAvmPath));