Opened 12 years ago

Closed 12 years ago

#1868 closed defect (fixed)

A couple of syntax errors in Compiler/Template/CodegenXML.tpl

Reported by: janssen Owned by: janssen
Priority: normal Milestone: 1.9.0
Component: Backend Version:
Keywords: Cc:

Description

CodegenXML.tpl gets the top-level declaration wrong, and has a couple of bugs with Boolean types. This means it can't be parsed by tools. Attached is a patch for these issues. After application, the generated XML actually validates. If I don't hear otherwise, I'll apply the patch in a day or two.

Attachments (1)

CodegenXML.tpl.patch (2.0 KB) - added by janssen 12 years ago.

Download all attachments as: .zip

Change History (5)

Changed 12 years ago by janssen

comment:1 Changed 12 years ago by alash325

  1. Regarding top level declaration If we look at the current declaration

<OpenModelicaModelDescription>
xmlns:exp="https://svn.jmodelica.org/trunk/XML/daeExpressions.xsd"
xmlns:equ="https://svn.jmodelica.org/trunk/XML/daeEquations.xsd"
xmlns:fun="https://svn.jmodelica.org/trunk/XML/daeFunctions.xsd"
xmlns:opt="https://svn.jmodelica.org/trunk/XML/daeOptimization.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
<%modelDescriptionXml(simCode,guid)%>
<%vendorAnnotationsXml(simCode)%>
<%defaultExperiment(simulationSettingsOpt)%>
<%modelVariablesXml(modelInfo)%>

.
.
.

</OpenModelicaModelDescription>

Where <OpenModelicaModelDescription> is opened at the top and closed at the end like this </OpenModelicaModelDescription>.

It seems quite ok .

What is your motivation to do like this.

<OpenModelicaModelDescription

xmlns:exp="https://svn.jmodelica.org/trunk/XML/daeExpressions.xsd"
xmlns:equ="https://svn.jmodelica.org/trunk/XML/daeEquations.xsd"
xmlns:fun="https://svn.jmodelica.org/trunk/XML/daeFunctions.xsd"
xmlns:opt="https://svn.jmodelica.org/trunk/XML/daeOptimization.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

<%modelDescriptionXml(simCode,guid)%>

  1. Regarding Boolean types.

Yes I agree with closing the opened tag <exp:BooleanLiteral> by </exp:BooleanLiteral>. I missed to close it.

However,regarding replacement of 'if bool then "1" else "0"' by (if bool then "1" else "0") ---I don't have any comment.

comment:2 Changed 12 years ago by janssen

  1. The xmlns expressions must be attributes on the top-level element, not freely-occurring strings in the body of the element. That's why the trailing greater-than sign must be moved.
  1. The expression <%if bool then "1" else "0"%> is just wrong -- the template system doesn't evaluate it. It's clear what needs to happen there -- my changes just make it happen.
  1. Really, there should be a test case or two for this -- and they should validate the generated XML. Say, by running it through the W3C's validator at http://validator.w3.org/.

comment:3 Changed 12 years ago by janssen

  • Owner changed from somebody to janssen
  • Status changed from new to accepted

I'd also suggest renaming some of the functions depending on what they do. For instance, "modelDescriptionXml" should really be called "modelDescriptionAttributes", because that's what it generates. Whereas "vendorAnnotationsXml" should be called "VendorAnnotationsElement", because that's what it generates. That would make it easier for other people to work on this code in the future.

comment:4 Changed 12 years ago by janssen

  • Resolution set to fixed
  • Status changed from accepted to closed

Fixed in revision 13277.

Note: See TracTickets for help on using tickets.