Author: ajaquith
Date: Mon Oct 6 09:07:52 2008
New Revision: 702184
URL: http://svn.apache.org/viewvc?rev=702184&view=rev
Log:
Added XML declaration parsing to JspParser.
Modified:
incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/webdocs/templates/default/AttachmentTab.jsp
incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/webdocs/templates/default/editors/plain.jsp
incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/ui/stripes/AbstractNode.java
incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/ui/stripes/JSPWikiJspTransformer.java
incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/ui/stripes/JspParser.java
incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/ui/stripes/JspParserTest.java
incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/ui/stripes/NodeType.java
Modified:
incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/webdocs/templates/default/AttachmentTab.jsp
URL:
http://svn.apache.org/viewvc/incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/webdocs/templates/default/AttachmentTab.jsp?rev=702184&r1=702183&r2=702184&view=diff
==============================================================================
---
incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/webdocs/templates/default/AttachmentTab.jsp
(original)
+++
incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/webdocs/templates/default/AttachmentTab.jsp
Mon Oct 6 09:07:52 2008
@@ -48,7 +48,6 @@
</table>
</form>
- </wiki:Permission>
<wiki:Messages div="error" />
</wiki:Permission>
<wiki:Permission permission="!upload">
Modified:
incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/webdocs/templates/default/editors/plain.jsp
URL:
http://svn.apache.org/viewvc/incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/webdocs/templates/default/editors/plain.jsp?rev=702184&r1=702183&r2=702184&view=diff
==============================================================================
---
incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/webdocs/templates/default/editors/plain.jsp
(original)
+++
incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/webdocs/templates/default/editors/plain.jsp
Mon Oct 6 09:07:52 2008
@@ -212,3 +212,5 @@
<label for="autopreview" title="<fmt:message
key='editor.plain.sneakpreview.title'/>"><fmt:message
key="editor.plain.sneakpreview"/></label>
</div>
<div id="sneakpreview"/></div>
+
+</div>
\ No newline at end of file
Modified:
incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/ui/stripes/AbstractNode.java
URL:
http://svn.apache.org/viewvc/incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/ui/stripes/AbstractNode.java?rev=702184&r1=702183&r2=702184&view=diff
==============================================================================
---
incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/ui/stripes/AbstractNode.java
(original)
+++
incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/ui/stripes/AbstractNode.java
Mon Oct 6 09:07:52 2008
@@ -207,7 +207,8 @@
public boolean isHtmlNode()
{
return m_type == NodeType.HTML_START_TAG || m_type ==
NodeType.HTML_COMBINED_TAG || m_type == NodeType.UNRESOLVED_HTML_TAG
- || m_type == NodeType.HTML_END_TAG;
+ || m_type == NodeType.HTML_END_TAG || m_type ==
NodeType.DECLARATION || m_type == NodeType.HTML_LINK
+ || m_type == NodeType.HTML_META;
}
/*
Modified:
incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/ui/stripes/JSPWikiJspTransformer.java
URL:
http://svn.apache.org/viewvc/incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/ui/stripes/JSPWikiJspTransformer.java?rev=702184&r1=702183&r2=702184&view=diff
==============================================================================
---
incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/ui/stripes/JSPWikiJspTransformer.java
(original)
+++
incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/ui/stripes/JSPWikiJspTransformer.java
Mon Oct 6 09:07:52 2008
@@ -32,17 +32,20 @@
// Advise user about <input type="hidden"> or <stripes:hidden>
tags
boolean isTypeHidden = false;
- isTypeHidden = "stripes:hidden".equals( tag.getName() ) &&
tag.getType() != NodeType.HTML_END_TAG;
- if( "input".equals( tag.getName() ) )
+ if ( tag.getType() != NodeType.HTML_END_TAG )
{
- Attribute attribute = tag.getAttribute( "type" );
- isTypeHidden = "hidden".equals( attribute.getValue() );
- }
- if( isTypeHidden )
- {
- Attribute hidden = tag.getAttribute( "name" );
- message( hidden, "NOTE: hidden form input with name \"" +
hidden.getValue()
- + "\" should probably correspond to a
Stripes ActionBean getter/settter. Refactor?" );
+ isTypeHidden = "stripes:hidden".equals( tag.getName() );
+ if( "input".equals( tag.getName() ) )
+ {
+ Attribute attribute = tag.getAttribute( "type" );
+ isTypeHidden = "hidden".equals( attribute.getValue() );
+ }
+ if( isTypeHidden )
+ {
+ Attribute hidden = tag.getAttribute( "name" );
+ message( hidden, "NOTE: hidden form input with name
\"" + hidden.getValue()
+ + "\" should probably correspond to a
Stripes ActionBean getter/settter. Refactor?" );
+ }
}
// Tell user about <wiki:Messages> tags.
Modified:
incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/ui/stripes/JspParser.java
URL:
http://svn.apache.org/viewvc/incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/ui/stripes/JspParser.java?rev=702184&r1=702183&r2=702184&view=diff
==============================================================================
---
incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/ui/stripes/JspParser.java
(original)
+++
incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/ui/stripes/JspParser.java
Mon Oct 6 09:07:52 2008
@@ -179,8 +179,7 @@
ParseContext ctx = ParseContext.currentContext();
// Figure out what this tag is
- String lookahead = ctx.lookahead( 4 );
- String lookahead10= ctx.lookahead( 10 );
+ String lookahead = ctx.lookahead( 10 );
JspDocument doc = ctx.getDocument();
// <%- means hidden JSP comment
@@ -223,14 +222,20 @@
}
}
+ // <? means declaration, such as XML declaration
+ else if ( lookahead.startsWith( NodeType.DECLARATION.getTagStart()
) )
+ {
+ initNode( new Tag( doc, NodeType.DECLARATION ), Stage.NAME );
+ }
+
// <!DOCTYPE means DOCTYPE
- else if ( lookahead10.startsWith( NodeType.DOCTYPE.getTagStart() )
)
+ else if ( lookahead.startsWith( NodeType.DOCTYPE.getTagStart() ) )
{
initNode( new Text( doc, NodeType.DOCTYPE ),
Stage.CODE_OR_COMMENT );
}
// <![CDATA[ means CDATA
- else if( lookahead10.startsWith( NodeType.CDATA.getTagStart() ) )
+ else if( lookahead.startsWith( NodeType.CDATA.getTagStart() ) )
{
initNode( new Text( doc, NodeType.CDATA ),
Stage.CODE_OR_COMMENT );
}
@@ -305,6 +310,7 @@
{
case ('/'):
case (' '):
+ case ('?'):
case ('%'): {
break;
}
@@ -543,7 +549,7 @@
if( lookahead.length() == 2 )
{
char nextChar = lookahead.charAt( 1 );
- if(
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!/%_:".indexOf( nextChar )
!= -1 )
+ if(
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!/%_:?".indexOf( nextChar
) != -1 )
{
ctx.setParser( TAG_PARSER,
Stage.TAG_START, 0 );
}
Modified:
incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/ui/stripes/JspParserTest.java
URL:
http://svn.apache.org/viewvc/incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/ui/stripes/JspParserTest.java?rev=702184&r1=702183&r2=702184&view=diff
==============================================================================
---
incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/ui/stripes/JspParserTest.java
(original)
+++
incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/ui/stripes/JspParserTest.java
Mon Oct 6 09:07:52 2008
@@ -14,6 +14,26 @@
super( s );
}
+ public void testDeclaration() throws Exception
+ {
+ String s = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><html/>";
+
+ // Parse the contents
+ JspParser parser = new JspParser();
+ JspDocument doc = parser.parse( s );
+
+ // Verify 2 nodes total
+ List<Node> nodes = doc.getNodes();
+ assertEquals( 2, nodes.size() );
+
+ // First node is XML declaration
+ Tag node = (Tag)nodes.get( 0 );
+ assertEquals( "xml", node.getName() );
+ assertEquals( null, node.getValue() );
+ assertEquals( NodeType.DECLARATION, node.getType() );
+ assertEquals( 2, node.getAttributes().size() );
+ }
+
public void testParseDoctype() throws Exception
{
String s = "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0
Transitional//EN\" http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">";
@@ -29,6 +49,7 @@
assertEquals( "(TEXT)", node.getName() );
assertEquals( NodeType.DOCTYPE, node.getType() );
assertEquals( "html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\"
http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\"", node.getValue() );
+ assertEquals( s, node.toString() );
}
public void testMeta() throws Exception
@@ -50,6 +71,7 @@
assertEquals( "Author", tag.getAttribute( "name" ).getValue() );
assertEquals( "content", tag.getAttribute( "content" ).getName() );
assertEquals( "Dave Raggett", tag.getAttribute( "content" ).getValue()
);
+ assertEquals( s, tag.toString() );
}
public void testLink() throws Exception
Modified:
incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/ui/stripes/NodeType.java
URL:
http://svn.apache.org/viewvc/incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/ui/stripes/NodeType.java?rev=702184&r1=702183&r2=702184&view=diff
==============================================================================
---
incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/ui/stripes/NodeType.java
(original)
+++
incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/ui/stripes/NodeType.java
Mon Oct 6 09:07:52 2008
@@ -27,6 +27,8 @@
HTML_META("<",">"),
/** HTML end tag */
HTML_END_TAG("</", ">"),
+ /** XML declaration, <em>e.g.</em>, <code><?xml version="1.0"
encoding="UTF-8"?></code>. */
+ DECLARATION("<?","?>"),
/** HTML end tag */
HTML_COMBINED_TAG("<", "/>"),
/** HTML tag, but not sure whether it's a start, end or combined tag. */