Page 1 of 1

xml cleaning and attribute removing

Posted: Wed Jul 18, 2007 5:46 pm
by lux
hi!

i would like to edit an xml file in the following way:

delete certain attributes in the whole document at once
(or maybe export needed content to a new file)

the info looks like this:

<Placemark>
<description><table style='width:100%'><tr valign='top'><td align='justify'>Eresin Crown Hotel is located in Sultanahmet, the heart of Istanbul's historical part, adjacent to the tourist, business, entertainment and shopping areas.<br /><br />In order to admire Istanbul's museums and architectural wonders you do not need to stay in line and wait... In addition to the personalised quality service and comfort; we have created for you in the Eresin Crown Hotel a private museum comprising a cistern, mosaic and 49 historical and architectural extraordinary museum pieces from the Hellenistic and Byzantine time. All of these historical and architectural heritage pieces are officially registered by the archaelogical museum of Istanbul. <br /><br /><a target=_blank href='http://www.mashedhotels.com/60086045' >More Information</a></td><td style='padding-left:8px;paddding-bottom:8px; align=right><a target=_blank href='http://www.mashedhotels.com/60086045' ><img src='http://www.mashedhotels.com/img/45/60086045n.jpg' title="Eresin Crown Hotel" alt='' ></a></td></tr></table></description>
<name>Eresin Crown Hotel</name>
<LookAt>
<longitude>28.97226</longitude>
<latitude>41.00419</latitude>
<range>0</range>
<tilt>0</tilt>
<heading>3</heading>
<coordinates>28.97226,41.00419,0</coordinates>
</LookAt>
<Point>
<coordinates>28.97226,41.00419,0</coordinates>
</Point>
<address> Istanbul, Istanbul 344 00, Turkey</address>
</Placemark>

i want to get this result:

<Placemark>
<name>Eresin Crown Hotel</name>
<coordinates>28.97226,41.00419,0</coordinates>
<address> Istanbul, Istanbul 344 00, Turkey</address>
</Placemark>

i didnt find any export solution to select wich attributes should be skipped..

is it possible to do such an export in oxygen?

many thanks!
lux

Posted: Wed Jul 18, 2007 8:27 pm
by jkmyoung
Simply create a filter on your Placemark template to only copy the information you need:
<xsl:template match="Placemark">
<xsl:copy>
<xsl:copy-of select="name|LookAt/coordinates|address"/>
</xsl:copy>
</xsl:template>

Posted: Wed Jul 18, 2007 11:23 pm
by lux
ok that looks promising! tnx :)

actually i found sort of a filter, but its only used to "hide" attributes and i dont exactly understand where i have to put that information in you sent me.

is this a transformation i have to execute in "document"->"transformation" ?

tnx again!

lux

Posted: Thu Jul 19, 2007 4:52 pm
by sorin_ristache
Hello,

Yes, it is a transformation which you execute with the action Document -> Transformation -> Apply Transformation Scenario. The same action is available on the Transformation toolbar. You define a transformation scenario with the action Configure Transformation Scenario. You apply the scenario with the action Apply Transformation Scenario.


Regards,
Sorin

Posted: Sat Jul 21, 2007 5:46 pm
by lux
ok!

so i configured the transformation, used the file i wish to transform as input and the above stated code in a xsl-file stored as xslt

result:
F [Saxon6.5.5] The prefix "xsl" for element "xsl:template" is not bound.


my knowledge about xml and the like seems very limited i guess now ;)

Posted: Mon Jul 23, 2007 11:09 am
by sorin_ristache
Hello,

The xsl prefix is for the XSLT namespace and should be declared on the root element of the XSLT stylesheet:

Code: Select all

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
You should read an XSLT tutorial.


Regards,
Sorin