cancel
Showing results for 
Search instead for 
Did you mean: 

Define invisible element in xsd, Possible??

xexiz
Champ in-the-making
Champ in-the-making
Hello, here's what I am trying to do.. tell me if it's possible and how it is plz Smiley Happy

I would like to add an element in my xsd schema that won't appear in the XForms, like adding a node "CreationDate" which will contain the date when you create this xml. but I dont want this to be visible in the Alfresco UI form. Just want this element in the final xml generated by the form, with the today's date!

Thanks Smiley Happy
12 REPLIES 12

xexiz
Champ in-the-making
Champ in-the-making
Yeah! Finally, no more error, but the element I'm including by the JSP does not apear in the final generated XML Smiley Sad

JSP:
<?xml version="1.0" encoding="utf-8" ?>
<xs:schema elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:element default="2008-01-25" name="creationDate" type="xs:date" />
</xs:schema>

XML result:


<News>
<Content lang="en">
<Title>d</Title>
<Body>d</Body>
</Content>
<Type>Financial Results</Type>
<PublishingDate>2008-01-08</PublishingDate>
<NbForIndex>2</NbForIndex>
</News>

XSD:
<?xml version="1.0" encoding="utf-8" ?>
<!– Created with Liquid XML Studio 1.0.7.0 (http://www.liquid-technologies.com) –>
<xs:schema xmlns:alf="http://www.alfresco.org" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:include schemaLocation="/getCreationDate.jsp" />
  <xs:element name="News">
    <xs:complexType>
      <xs:sequence>
        <xs:element minOccurs="1" maxOccurs="2" name="Content">
          <xs:complexType>
            <xs:sequence>
              <xs:element name="Title" type="xs:normalizedString" />
              <xs:element name="Body" type="xs:string" />
            </xs:sequence>
            <xs:attribute name="lang">
              <xs:simpleType>
                <xs:restriction base="xs:normalizedString">
                  <xs:enumeration value="en">
                    <xs:annotation>
                      <xs:appinfo>
                        <alf:label xmlns:alf="http://www.alfresco.org">English</alf:label>
                      </xs:appinfo>
                    </xs:annotation>
                  </xs:enumeration>
                  <xs:enumeration value="fr">
                    <xs:annotation>
                      <xs:appinfo>
                        <alf:label xmlns:alf="http://www.alfresco.org">Français</alf:label>
                      </xs:appinfo>
                    </xs:annotation>
                  </xs:enumeration>
                </xs:restriction>
              </xs:simpleType>
            </xs:attribute>
          </xs:complexType>
        </xs:element>
        <xs:element name="Type">
          <xs:simpleType>
            <xs:restriction base="xs:normalizedString">
              <xs:enumeration value="Financial Results" />
              <xs:enumeration value="Internal Communications" />
            </xs:restriction>
          </xs:simpleType>
        </xs:element>
        <xs:element name="PublishingDate" type="xs:date" />
        <xs:element name="NbForIndex" type="xs:integer">
          <xs:annotation>
            <xs:appinfo>
              <alf:label xmlns:alf="http://www.alfresco.org">How much will appear on index?</alf:label>
            </xs:appinfo>
          </xs:annotation>
        </xs:element>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
</xs:schema>

EDIT 10h47AM:
What type the JSP should be anyways? because i'm trying to switch to this code and it's always interpret wrong when I try the "preview file" I've try to create it with XML. HTML, and Java Class type.. without success

it's always display this when I click preview file:
" name="" type="">

<jsp:root version="1.2" xmlns:jsp="http://java.sun.com/JSP/Page" xmlns:c="http://java.sun.com/jsp/jstl/core">
<jsp:directive.page language="java" contentType="text/html" isELIgnored="false"/>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:alf="http://www.alfresco.org/alfresco" elementFormDefault="qualified">
   <jsp:element name="xs:element">
      <jsp:attribute name="name"><c:out value="CreationDate"></c:out></jsp:attribute>
      <jsp:attribute name="type"><c:out value="xs:date" ></c:out></jsp:attribute>
      <jsp:attribute name="default"><c:out value="2008-01-24" ></c:out></jsp:attribute>
      <jsp:body>
         <xs:annotation>
            <xs:appinfo>
               <alf:label><c:out value="Creation Date"/></alf:label>
            </xs:appinfo>
         </xs:annotation>
      </jsp:body>
   </jsp:element>   
</xs:schema>
</jsp:root>
[img]http://img81.imageshack.us/img81/695/addjspma1.jpg[/img]

kvc
Champ in-the-making
Champ in-the-making
If you preview via the virtualization server the included JSP from within your sandbox, you'll need see that the JSP is generating a valid schema output.  Currently, sounds like from your earlier post this is what your JSP is generating:

<?xml version="1.0" encoding="utf-8" ?>
<xs:schema xmlns:alf="http://www.alfresco.org/alfresco" xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
   <xs:simpleType name="creation_date">
      <xs:restriction base="xs:normalizedString">
         <xs:normalizedString value="2008-01-25">
            <xs:annotation>
               <xs:appinfo>
                  <alf:label>CreationDate</alf:label>
               </xs:appinfo>
            </xs:annotation>
         </xs:normalizedString>
      </xs:restriction>
   </xs:simpleType>
</xs:schema>


To make your schema valid, you'll need to generate the following:


<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
           elementFormDefault="qualified">
  <xs:simpleType name="creation_date">
    <xs:restriction base="xs:normalizedString">
      <xs:enumeration value="2008-01-25">
            <xs:annotation>
               <xs:appinfo>
                  <alf:label>CreationDate</alf:label>
               </xs:appinfo>
            </xs:annotation>
      </xs:enumeration>
    </xs:restriction>
  </xs:simpleType>
</xs:schema>

Try that … should help.


Kevin

xexiz
Champ in-the-making
Champ in-the-making
Thanks Kevin!
Your example is working, but it's now printing an option field, my optimal goal is to be able to add the creation date into the generated xml without the user see it, I doubt I will be able to hide this option field.. with a text field I would be able, I think.. or at least made it disable if I really cant make it disapear..

thx, my form is progressing! Smiley Happy