01: /* Copyright 2001 The JA-SIG Collaborative. All rights reserved.
02: * See license distributed with this file and
03: * available online at http://www.uportal.org/license.html
04: */
05:
06: /**
07: * Filter incorporating channel attributes for the second
08: * (theme) XSLT transformation.
09: * @author Peter Kharchenko
10: * @version $Revision: 34820 $
11: */package org.jasig.portal;
12:
13: import java.util.Enumeration;
14:
15: import org.jasig.portal.utils.SAX2FilterImpl;
16: import org.xml.sax.Attributes;
17: import org.xml.sax.ContentHandler;
18: import org.xml.sax.SAXException;
19: import org.xml.sax.XMLReader;
20: import org.xml.sax.helpers.AttributesImpl;
21:
22: public class ThemeAttributesIncorporationFilter extends SAX2FilterImpl {
23: protected ThemeStylesheetUserPreferences tsup;
24:
25: // downward
26: public ThemeAttributesIncorporationFilter(ContentHandler handler,
27: ThemeStylesheetUserPreferences prefs) {
28: super (handler);
29: this .tsup = prefs;
30: }
31:
32: // upward
33: public ThemeAttributesIncorporationFilter(XMLReader parent,
34: ThemeStylesheetUserPreferences prefs) {
35: super (parent);
36: this .tsup = prefs;
37: }
38:
39: public void startElement(String uri, String localName,
40: String qName, Attributes atts) throws SAXException {
41: // recognizing "channel"
42: if (qName.equals("channel")) {
43: AttributesImpl attsImpl = new AttributesImpl(atts);
44: String channelSubscribeId = attsImpl.getValue("ID");
45: for (Enumeration ca = tsup.getChannelAttributeNames(); ca
46: .hasMoreElements();) {
47: String attrName = (String) ca.nextElement();
48: attsImpl.addAttribute("", attrName, attrName, "CDATA",
49: tsup.getChannelAttributeValue(
50: channelSubscribeId, attrName));
51: }
52: super.startElement(uri, localName, qName, attsImpl);
53: } else {
54: super.startElement(uri, localName, qName, atts);
55: }
56: }
57: }
|