• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Bear Bibeault
  • Junilu Lacar
  • Martin Vashko
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Scott Selikoff
  • salvin francis
  • Piet Souris

Problem with <util:map - Invalid nested exception is org.xml.sax.SAXParseException

 
Ranch Hand
Posts: 265
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,
for a detected device I would like to use an appropriate xsl file.
To do this I have created a DeviceDisplayDetector object I have attempted to inject in
deviceDisplayTypes so that I can get at the associated xsl for the device that has made a request.

The configuration code within my applicationContext.xml is as follows:-

<bean id="deviceDetector" class="my.DeviceDisplayDetector">
<property name="deviceDisplayTypes"><ref bean="deviceDisplayTypes"/></property>
</bean>

<!-- Setup PC specific attributes -->
<util:map id="deviceDisplayTypes" map-class="java.util.HashMap">
<property name="PC"><ref bean="pcDeviceAttrib"/></property>
<property name="MOBILE"><ref bean="mobileDeviceAttrib"/></property>
</util:map>

<util:map id="pcDeviceAttrib" map-class="java.util.HashMap">
<entry key="my.vo.FootBallImageVO" value="PC_FootBallImageVO.xsl"/>
<entry key="my.ce.TennisImageVO" value="PC_TennisImageVO.xsl"/>
</util:map>

<util:map id="mobileDeviceAttrib" map-class="java.util.HashMap">
<entry key="my.vo.FootBallImageVO" value="MOBILE_FootBallImageVO.xsl"/>
<entry key="my.ce.TennisImageVO" value="MOBILE_TennisImageVO.xsl"/>
</util:map>

I keep getting the following error:-
applicationContext.xml] is invalid; nested exception is org.xml.sax.SAXParseException:
<Line 96, Column 12>: XML-20148: (Error) Invalid element 'util:map' in content of 'beans', expected elements '[import, alias, bean]'.

Any ideas

Mat
 
Mat Anthony
Ranch Hand
Posts: 265
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can a bean ref a util:map as in my example, or can anybody suggest a better way.
 
Mat Anthony
Ranch Hand
Posts: 265
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can some kind person help me with this problem

Mat
 
Bartender
Posts: 4121
IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What's the namespace definition of your beans XML look like? Have you defined the "util" namespace?
 
Mat Anthony
Ranch Hand
Posts: 265
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Nathan,
Thanks for the reply.

I just looked inside my applicationContext.xml and have noticed, that I just have the following defined:-

file:applicationContext.xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD//BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
<beans>

<bean id="deviceDetector" class="my.DeviceDisplayDetector">
<property name="deviceDisplayTypes"><ref bean="deviceDisplayTypes"/></property>
</bean>

<!-- Setup PC specific attributes -->
<util:map id="deviceDisplayTypes" map-class="java.util.HashMap">
<property name="PC"><ref bean="pcDeviceAttrib"/></property>
<property name="MOBILE"><ref bean="mobileDeviceAttrib"/></property>
</util:map>

<util:map id="pcDeviceAttrib" map-class="java.util.HashMap">
<entry key="my.vo.FootBallImageVO" value="PC_FootBallImageVO.xsl"/>
<entry key="my.ce.TennisImageVO" value="PC_TennisImageVO.xsl"/>
</util:map>

<util:map id="mobileDeviceAttrib" map-class="java.util.HashMap">
<entry key="my.vo.FootBallImageVO" value="MOBILE_FootBallImageVO.xsl"/>
<entry key="my.ce.TennisImageVO" value="MOBILE_TennisImageVO.xsl"/>
</util:map>

</beans>


Do I need to include the following as well :-

<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:util="http://www.springframework.org/schema/util" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-2.0.xsd">


Mat
 
Mat Anthony
Ranch Hand
Posts: 265
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Nathan,
thanks for the reply, I just added:-

<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:util="http://www.springframework.org/schema/util" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-2.0.xsd">

and it seems to work fine

Mat
 
Screaming fools! It's nothing more than a tiny ad:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!