BIM Coordinator Program (INT) April 22, 2024

Find the next step in your career as a Graphisoft Certified BIM Coordinator!

Archicad C++ API
About Archicad add-on development using the C++ API.

XML Library Developer Tool Problem in 9

TomWaltz
Participant
I had been experimenting with the Library Developer tool to convert GSM object files to XML files with the Archicad 8.1 library with great success in converting files.

In trying to use it on the Archicad 9 library, I am finding that the results are not as good.

To use it, I extracted Archicad Library 9.pla to a directory, Archicad9.lib/ I then ran the utility, LP_XMLConverter l2x <source> <dest>.

The utility seemed to be working, as files scrolled by in the terminal window. Upon completion, I found that the tool simply copied the GSM and raster files, but did not convert any of them to XML.

I am using LibDevTool_9_1810_Mac, on a Dual 2 GHz G5, running macOS 10.3.5.

Has anyone else gotten this to work in Archicad 9?
Tom Waltz
15 REPLIES 15
Andras Babos
Graphisoft Alumni
Graphisoft Alumni
Well, almost...

Consider this example XML:
 
<example> 
  <value/> 
  <container> 
    <list> 
    </list> 
    <interestingValue/> 
  </container> 
  <otherContainer> 
    <list> 
    </list> 
  <otherContainer> 
</example> 

Now if you want to change the <interestingValue> then you'd need something like this:
 
<!-- change the value of interestingValue -> 
<xsl:template match="example/container/interestingValue"> 
  <!-- do something here --> 
</xsl:template> 
 
<!-- copy everything else in container --> 
<xsl:template match="example/container/*[name () != 'interestingValue']"> 
  <xsl:copy-of select="."/> 
</xsl:template> 
 
<!-- copy container --> 
<xsl:template match="example/container"> 
  <xsl:copy> 
    <xsl:apply-templates/> 
  </xsl:copy> 
</xsl:template> 
 
<!-- copy everything that's not a container --> 
<xsl:template match="example/*[name () != 'container']"> 
  <xsl:copy-of select="."/> 
</xsl:template> 
 
<!-- copy the whole document, applying changes --> 
<xsl:template match="example"> 
  <xsl:copy> 
    <xsl:apply-templates/> 
  </xsl:copy> 
</xsl:template> 

See? It's hierarchical. You have to change what you want, and copy "everything else".

HTH:
Andras Babos.
TomWaltz
Participant
<crowd> OOOH! <crowd/>

I get it.

This sounds like it has some serious possibilities, without the agony of learning Perl and RegEx.

Although, that means I now get to learn ANOTHER language.

Thanks!!
Tom Waltz
TomWaltz
Participant
Andras

I guess my question now is if you have used any kind of scripting with this in the past. It seems as though every XML file will need to have both the DTD and the XSL file called out in it.

Since we are talking about 1500 or so XML files, is there some method you have used to add the needed text to every XML file, then run the transformation on all the files?

-Tom
Tom Waltz
Andras Babos
Graphisoft Alumni
Graphisoft Alumni
TomWaltz wrote:
Andras

I guess my question now is if you have used any kind of scripting with this in the past. It seems as though every XML file will need to have both the DTD and the XSL file called out in it.

Since we are talking about 1500 or so XML files, is there some method you have used to add the needed text to every XML file, then run the transformation on all the files?

-Tom

1. Use the Schema, not the DTD if possible. To put it simply XML Schema is the "next gen" DTD.
2. You only need the DTD referenced from the file if you want automatic inline validation. (IIRC even Explorer doesn't do that automatically.)
3. You'd need the XSL file referenced from the XML file if you wanted to apply the transformations on the fly when opening the XML files with a browser. But opening it won't save the changes back!

What you need is a decent XSL processor like Xalan (it also needs the XML parser, that's Xerces). It has a command line utility and also an API. I guess you'll be fine with just the command line tool.
The basic syntax is:
Xalan xml_source_file xsl_stylesheet

This applies the xsl_stylesheet on the xml_source_file and prints the result.

Andras.
TomWaltz
Participant
Andras

you're right, XSLT is really nice. I'm working my way through the O'Reilly XSLT book now, as part of their XML CD bookshelf.

Tons of power, I just have to learn how to tell it what I want and what exactly I'm trying to change.

As the title of one chapter says, it really is a method of describing needles and haystacks.

Thanks!
Tom Waltz
Frank Beister
Advisor
This thread sounds very interesting. Maybe it's possible to insert additional pictures in existing objects in this way? Would be very helpful.

But maybe I have two left thumbs today: I don't get the LibDevTool to run under MacOS X 10.3.9. The file, which should be the executable is a text file. (Extracted by stuffit expander.)
bim author since 1994 | bim manager since 2018 | author of selfGDL.de | openGDL | skewed archicad user hall of fame | author of bim-all-doors.gsm
Learn and get certified!