cancel
Showing results for 
Search instead for 
Did you mean: 

No XML tags instead of attribute xsi:nil='true'

trgerhardt
Champ in-the-making
Champ in-the-making
How do you code an XSD so that the tags just don't show up if there is no content instead of having xsi:nil="true"?

XSD File:
<?xml version="1.0" encoding="utf-8"?>

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

  <xs:include schemaLocation="/includes/schemas/Public Images.xsd"/>

  <xs:element name="object" type="objectType" />

  <xs:complexType name="objectType">
    <xs:sequence>
      <xs:element name="name" type="xs:normalizedString" />
      <xs:element name="image" type="imageType" minOccurs="0" />
      <xs:element name="post" maxOccurs="unbounded">
        <xs:complexType>
          <xs:sequence>
            <xs:element name="title" type="xs:normalizedString" />
            <xs:element name="url" type="xs:normalizedString" minOccurs="0" />
            <xs:element name="date" type="xs:date" minOccurs="0" />
            <xs:element name="image" type="imageType" minOccurs="0" />
            <xs:element name="body" type="xs:string" />
          </xs:sequence>
        </xs:complexType>
      </xs:element>
    </xs:sequence> 
  </xs:complexType>
   
</xs:schema>

XML Printed:
<object>
  <name>Test</name>
    <image xsi:nil="true">
      <title xsi:nil="true"/>
      <filename xsi:nil="true"/>
    </image>
    <post>
      <title>test</title>
      <url xsi:nil="true"/>
      <date xsi:nil="true"/>
      <image xsi:nil="true">
        <title xsi:nil="true"/>
        <filename xsi:nil="true"/>
      </image>
    <body>test</body>
  </post>
</object>
3 REPLIES 3

arielb
Champ in-the-making
Champ in-the-making
for optional tags (minOccurs="0") i need to use xsi:nil in order to preserve the document structure.  there is no alternative at the moment - the nil tags are needed in order to keep the xforms processor happy.  if this is important to you, please file an issue at issues.alfresco.com and i'll look into resolving this for a future release.

trgerhardt
Champ in-the-making
Champ in-the-making
Ok Then how do you test for the xsi:nil attribute? Everything I've tried has resulted in errors.

<xsl:if test="@xsi:nil='false'>

Results in an error, what would be the proper way to do this?

arielb
Champ in-the-making
Champ in-the-making
not sure why you'd get an error - do you have the xsi namespace imported in your xsl?