# MazeMap.jsx Sample

This topic inludes the source code for the MazeMap.jsx Sample.

## Sample Location

This sample is located in the following directory in your WebLogic Workshop installation:

BEA_HOME/weblogic81/samples/workshop/SamplesApp/WebServices/proxy/mazegen/

## Sample Source Code

`01 package proxy.mazegen; 02 03 import proxy.mazegen.MazeGenerator.Maze; 04 05 function ConvertMazeToXML(maze) 06 { 07 resultXML = <maze></maze>; 08 resultXML.appendChild(<rows>{maze.rows}</rows>); 09 resultXML.appendChild(<cols>{maze.columns}</cols>); 10 rooms = <rooms></rooms>; 11 12 for (i = 0; i < maze.rows; i++) 13 { 14 for (j = 0; j < maze.columns; j++) 15 { 16 N = hasDoor(maze, i, j, i - 1, j); 17 S = hasDoor(maze, i, j, i + 1, j); 18 E = hasDoor(maze, i, j, i, j - 1); 19 W = hasDoor(maze, i, j, i, j + 1); 20 21 rooms.appendChild( 22 <room row={i} col={j}> 23 <hasNorthDoor>{N}</hasNorthDoor> 24 <hasSouthDoor>{S}</hasSouthDoor> 25 <hasEastDoor>{E}</hasEastDoor> 26 <hasWestDoor>{W}</hasWestDoor> 27 </room>); 28 } 29 } 30 31 resultXML.appendChild(rooms); 32 return resultXML; 33 } 34 35 function hasDoor(maze, row1, col1, row2, col2) 36 { 37 if ((row1 < 0) || (maze.rows <= row1)) 38 return false; 39 40 if ((col1 < 0) || (maze.columns <= col1)) 41 return false; 42 43 if ((row2 < 0) || (maze.rows <= row2)) 44 return false; 45 46 if ((col2 < 0) || (maze.columns <= col2)) 47 return false; 48 49 return maze.getConnected(row1, col1, row2, col2); 50 }`