[XSL-LIST Mailing List Archive Home]
[By Thread]
[By Date]
Re: step code to XML???
At 99/08/25 19:28 +0100, AposToliS Mikronis wrote:
I need to convert the following step code into an XML file.
I am not very familiar with XSL and XML and I don't know if it possible to
tranform something with no tags in it.
ENTITY buffer_gas_system SUBTYPE OF (plant_item)
ABSTRACT SUPERTYPE OF (centrifugal_compressor);
END_ENTITY;
ENTITY material_transfer_equipment SUBTYPE OF (process_equipment)
ABSTRACT SUPERTYPE OF (fluid_transfer_machine);
material_transfer_equipment_type : STRING;
END_ENTITY;
If I can't do it using XSL is there any other way??
Yes you can't do it with XSL (XSL requires at least a well-formed XML
input) and yes there is another way (among many).
Does anyone have any suggestions?
OmniMark is a very strong language and very robust.
It is also free, see: http://www.omnimark.com
An example is below.
I hope this helps.
........... Ken
T:\tolis>type test.txt
ENTITY buffer_gas_system SUBTYPE OF (plant_item)
ABSTRACT SUPERTYPE OF (centrifugal_compressor);
END_ENTITY;
ENTITY material_transfer_equipment SUBTYPE OF (process_equipment)
ABSTRACT SUPERTYPE OF (fluid_transfer_machine);
material_transfer_equipment_type : STRING;
END_ENTITY;
T:\tolis>type test.xom
CROSS-TRANSLATE
FIND-START
OUTPUT '<?xml version="1.0"?>%n<test>%n'
FIND-END
OUTPUT '</test>%n'
FIND WHITE-SPACE+
;eat superfluous white space
FIND "ENTITY" WHITE-SPACE+
[ANY EXCEPT WHITE-SPACE]+ => ent WHITE-SPACE+
( "SUBTYPE OF" WHITE-SPACE+
"(" [ANY EXCEPT WHITE-SPACE OR ")"]+ => sup ")" WHITE-SPACE* )?
( "ABSTRACT SUPERTYPE OF" WHITE-SPACE+
"(" [ANY EXCEPT WHITE-SPACE OR ")"]+ => abs ")" WHITE-SPACE* )?
";" WHITE-SPACE*
( [ANY EXCEPT WHITE-SPACE]+ => str
WHITE-SPACE+ ":" WHITE-SPACE+ "STRING" WHITE-SPACE* ";"
WHITE-SPACE+ )?
"END_ENTITY" WHITE-SPACE* ";"
OUTPUT "<entity><name>%x(ent)</name>%n"
OUTPUT "<subtype-of>%x(sup)</subtype-of>%n" WHEN sup IS SPECIFIED
OUTPUT "<abs-sup-of>%x(abs)</abs-sup-of>%n" WHEN abs IS SPECIFIED
OUTPUT '<object type="string">%x(str)</object>%n'
WHEN str IS SPECIFIED
OUTPUT "</entity>%n"
;end of file
T:\tolis>omnimark -s test.xom -of test.xml test.txt
T:\tolis>type test.xml
<?xml version="1.0"?>
<test>
<entity><name>buffer_gas_system</name>
<subtype-of>plant_item</subtype-of>
<abs-sup-of>centrifugal_compressor</abs-sup-of>
</entity>
<entity><name>material_transfer_equipment</name>
<subtype-of>process_equipment</subtype-of>
<abs-sup-of>fluid_transfer_machine</abs-sup-of>
<object type="string">material_transfer_equipment_type</object>
</entity>
</test>
T:\tolis>
--
G. Ken Holman mailto:gkholman@xxxxxxxxxxxxxxxxxxxx
Crane Softwrights Ltd. http://www.CraneSoftwrights.com/s/
Box 266, Kars, Ontario CANADA K0A-2E0 +1(613)489-0999 (Fax:-0995)
Website: XSL/XML/DSSSL/SGML services, training, libraries, products.
Practical Transformation Using XSLT and XPath ISBN 1-894049-01-2
Next instructor-led training: MT'99 1999-12-05/06
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|