Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to make an xml file call up another xml file

Status
Not open for further replies.

redgirl01

Technical User
Nov 26, 2009
1
AU
hi

I am new to XML and would like to do the following.

I have an XML file that loads calendar info into a swf file.

at the top of the 'news.xml' file there is a <news> tag containing xml that formats the text styling and background. The rest of the file contains <item> tags for the individual calendar dates & info.

My problem is that my client wants to edit the calendar item information himself but finds the xml file confusing and I worry he will delete parts of the code accidentally.

I would like to do the following:
1. keep the news.xml file & put the <news> in only then call up a second file called 'newscontent.xml'
2. 'newscontent.xml' file would contain all the <item> info.

this way I can setup in excel file to export the xml to 'newscontent.xml' and then client can easily update the info in excel


please see the original xml file attached.

can anyone show me what I need to do please. I tried but have failed.
 
[0] As a matter of principle, you should not work further on the end xml document destined to feed to flash application. It should be the end-result of a functional part. It should be produced by a document-centric xml document containing the information. Then, it is processed by some xslt-processor, say, to end up with the news.xml for the flash consumption. The reason is that news.xml contains tons of styling information. If you work further on that news.xml, you have to get rid of those styling. Hence, the work would not be efficient. Further, the styling can damage the original info structure beyond repair (or with lot of works to reverse the damage), hence, it is not very effective neither. To answer to your users' need, you should work from the original document, the one free of styling for flash.

[1] Having said that, I can show you an xsl to transform news.xml into text output again so that your users can use it to be process further by excel [sic]. Of course, you can have myriad of preferences, of style etc, I would not follow up on those requirements. I choose one format to show you the essential and you should be able to elaborate on it to your eventual format and/or what to retain and what not.
[tt]
<?xml version="1.0" encoding="utf-8" ?>
<xsl:stylesheet version="1.0" xmlns:xsl="[ignore][/ignore]">
<xsl:eek:utput method="text" omit-xml-declaration="yes" />
<xsl:template match="news">
<xsl:text>news&#x0a;&#x0a;</xsl:text>
<xsl:apply-templates select="item" />
</xsl:template>
<xsl:template match="item">
<xsl:text>item&#x0a;</xsl:text>
<xsl:text>date: </xsl:text>
<xsl:value-of select="concat(@month,' ',@date,',',@year,'&#x0a;')" />
<xsl:apply-templates select="summary|title|headline|subTitle|details" />
<xsl:text>&#x0a;</xsl:text>
</xsl:template>
<xsl:template match="summary|title|headline">
<xsl:value-of select="concat(local-name(),': ',.,'&#x0a;')" />
</xsl:template>
<xsl:template match="subTitle">
<xsl:variable name="content">
<xsl:value-of select="substring-before(substring-after(.,'>'),'<')" />
</xsl:variable>
<xsl:value-of select="concat(local-name(),': ',$content,'&#x0a;')" />
</xsl:template>
<xsl:template match="details">
<xsl:variable name="content">
<xsl:choose>
<xsl:when test="contains(.,'<h4>')">
<xsl:value-of select="substring-before(substring-after(.,'<h4>'),'</h4>')" />
</xsl:when>
<xsl:eek:therwise>
<xsl:value-of select="normalize-space()" />
</xsl:eek:therwise>
</xsl:choose>
</xsl:variable>
<xsl:value-of select="concat(local-name(),': ',$content,'&#x0a;')" />
</xsl:template>
</xsl:stylesheet>[/tt]
 
Notes:
After re-reading what I posted, there are places where the formatting mechanism of the forum distorted what I actually scripted.

[a]
[self]><xsl:value-of select="substring-before(substring-after(.,'>'),'<')" />

is actually being scripted ([highlight]without underscore in the highlighted part[/highlight]).

[tt]<xsl:value-of select="substring-before(substring-after(.,'[highlight]&_lt;[/highlight]'),'[highlight]&_gt;[/highlight]')" />[/tt]

The corresponding part should be read like this (always highlighted part without underscores).
[tt]
<xsl:when test="contains(.,'[highlight]&_lt;h4&_gt;[/highlight]')">
<xsl:value-of select="substring-before(substring-after(.,'[highlight]&_lt;h4&_gt;[/highlight]'),'[highlight]&_lt;/h4&_gt;[/highlight]')" />
</xsl:when>
[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top