xml cleaning and attribute removing

Questions about XML that are not covered by the other forums should go here.
lux
Posts: 3
Joined: Wed Jul 18, 2007 5:32 pm
Location: switzerland

xml cleaning and attribute removing

Post 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
jkmyoung
Posts: 89
Joined: Mon Mar 06, 2006 10:13 pm

Post 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>
lux
Posts: 3
Joined: Wed Jul 18, 2007 5:32 pm
Location: switzerland

Post 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
sorin_ristache
Posts: 4141
Joined: Fri Mar 28, 2003 2:12 pm

Post 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
lux
Posts: 3
Joined: Wed Jul 18, 2007 5:32 pm
Location: switzerland

Post 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 ;)
sorin_ristache
Posts: 4141
Joined: Fri Mar 28, 2003 2:12 pm

Post 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
Post Reply