Hi everyone,
I am just starting to learn XSL, but I am having a problem handling attributes in the example I am trying to work with. I have searched around for tutorials and such that may help me with this problem, but no luck so far.
I am using the XML file outputted by a data mining program called Lingpipe, and trying to style that data. Here is an example of the data that should give you a pretty good idea of what I'm working with:
This generated page came from entering part of the wikipedia article on Ford into the program. It separates the facts into bullet points, and sifts out names, organizations, locations, etc, and marks each of those with a corresponding TYPE attribute on the ENAMEX element.
So far, I have been able to separate the bullet point numbers (the "i" attribute in the "s" element), and then put each fact below it's number.
However, I am trying to find a way to make all words in the ENAMEX elements a different color, depending on the TYPE attribute. For example, all locations could be brown, and all organizations could be blue.
I tried a test to see if I could make all of the organization names bold. I doubted it would work, and I was right. Here is what I have:
All this does is list all of the words tagged as organizations at the end of each bit of information, although it does at least bold them.
I cannot figure out how to make this work in the middle of the sentence. Any help would be greatly appreciated.
Thank you.
I am just starting to learn XSL, but I am having a problem handling attributes in the example I am trying to work with. I have searched around for tutorials and such that may help me with this problem, but no luck so far.
I am using the XML file outputted by a data mining program called Lingpipe, and trying to style that data. Here is an example of the data that should give you a pretty good idea of what I'm working with:
Code:
<output>
<s i="0">
<ENAMEX TYPE="ORGANIZATION">Ford Motor Company</ENAMEX> is an American multinational corporation and the world's third largest automaker based on worldwide vehicle sales.
</s>
<s i="1">
In 2006, <ENAMEX TYPE="ORGANIZATION">Ford</ENAMEX> was the second-ranked automaker in the <ENAMEX TYPE="LOCATION">US</ENAMEX> with a 17.5% market share, behind <ENAMEX TYPE="ORGANIZATION">General Motors</ENAMEX> (24.6%) but ahead of <ENAMEX TYPE="ORGANIZATION">Toyota</ENAMEX> (15.4%) and <ENAMEX TYPE="ORGANIZATION">DaimlerChrysler</ENAMEX> (14.4%)[3].
</s>
<s i="2">
<ENAMEX TYPE="ORGANIZATION">Ford</ENAMEX> was also the seventh-ranked American-based company in the 2007 Fortune 500 list, based on global revenues of $160.1 billion <ENAMEX TYPE="LOCATION">[4].</ENAMEX>
</s>
</output>
This generated page came from entering part of the wikipedia article on Ford into the program. It separates the facts into bullet points, and sifts out names, organizations, locations, etc, and marks each of those with a corresponding TYPE attribute on the ENAMEX element.
So far, I have been able to separate the bullet point numbers (the "i" attribute in the "s" element), and then put each fact below it's number.
However, I am trying to find a way to make all words in the ENAMEX elements a different color, depending on the TYPE attribute. For example, all locations could be brown, and all organizations could be blue.
I tried a test to see if I could make all of the organization names bold. I doubted it would work, and I was right. Here is what I have:
Code:
<?xml version="1.0" encoding="windows-1252"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="[URL unfurl="true"]http://www.w3.org/1999/XSL/Transform">[/URL]
<xsl:template match="/">
<html>
<body>
<xsl:for-each select="output/s">
<p>
<b><xsl:value-of select="@i"/></b>
</p>
<p>
<xsl:value-of select="."/>
<xsl:for-each select="ENAMEX">
<xsl:if test="@TYPE='ORGANIZATION'">
<b><xsl:value-of select="."/></b>
</xsl:if>
</xsl:for-each>
</p>
</xsl:for-each>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
All this does is list all of the words tagged as organizations at the end of each bit of information, although it does at least bold them.
I cannot figure out how to make this work in the middle of the sentence. Any help would be greatly appreciated.
Thank you.