Skip to content

Commit

Permalink
Create JakartaEE Namespace Constant
Browse files Browse the repository at this point in the history
  • Loading branch information
volosied committed Mar 1, 2022
1 parent 22e865b commit 77963cd
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 30 deletions.
8 changes: 3 additions & 5 deletions tagsdoc/src/main/java/com/sun/tlddoc/Constants.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/*
* <license>
* Copyright (c) 2003-2004, Sun Microsystems, Inc.
* Copyright (c) 2022 Contributors to the Eclipse Foundation
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
Expand Down Expand Up @@ -50,11 +51,8 @@ private Constants() {
public static final String DEFAULT_DOC_TITLE =
"Tag Library Documentation Generator - Generated Documentation";

/** Namespace for Java EE */
public static final String NS_JAVAEE = "http://java.sun.com/xml/ns/javaee";

/** Namespace for J2EE */
public static final String NS_J2EE = "http://java.sun.com/xml/ns/j2ee";
/** Namespace for Jakarta EE */
public static final String NS_JAKARTAEE = "https://jakarta.ee/xml/ns/jakartaee";

/** If true, outputs the input to the transform before generation */
public static final boolean DEBUG_INPUT_DOCUMENT = false;
Expand Down
43 changes: 21 additions & 22 deletions tagsdoc/src/main/java/com/sun/tlddoc/TLDDocGenerator.java
Original file line number Diff line number Diff line change
Expand Up @@ -499,24 +499,24 @@ public InputSource resolveEntity (
summaryTLD = documentBuilder.newDocument();

// Create root <tlds> element:
Element rootElement = summaryTLD.createElementNS( Constants.NS_JAVAEE,
Element rootElement = summaryTLD.createElementNS( Constants.NS_JAKARTAEE,
"tlds" );
summaryTLD.appendChild( rootElement );
// JDK 1.4 does not add xmlns for some reason - add it manually:
rootElement.setAttributeNS( "http://www.w3.org/2000/xmlns/",
"xmlns", Constants.NS_JAVAEE );
"xmlns", Constants.NS_JAKARTAEE );

// Create configuration element:
Element configElement = summaryTLD.createElementNS( Constants.NS_JAVAEE,
Element configElement = summaryTLD.createElementNS( Constants.NS_JAKARTAEE,
"config" );
rootElement.appendChild( configElement );

Element windowTitle = summaryTLD.createElementNS( Constants.NS_JAVAEE,
Element windowTitle = summaryTLD.createElementNS( Constants.NS_JAKARTAEE,
"window-title" );
windowTitle.appendChild( summaryTLD.createTextNode( this.windowTitle));
configElement.appendChild( windowTitle );

Element docTitle = summaryTLD.createElementNS( Constants.NS_JAVAEE,
Element docTitle = summaryTLD.createElementNS( Constants.NS_JAKARTAEE,
"doc-title" );
docTitle.appendChild( summaryTLD.createTextNode( this.docTitle));
configElement.appendChild( docTitle );
Expand Down Expand Up @@ -551,11 +551,10 @@ public InputSource resolveEntity (

Element taglibNode = (Element)summaryTLD.importNode(
doc.getDocumentElement(), true );
if( !taglibNode.getNamespaceURI().equals( Constants.NS_JAVAEE )
&& !taglibNode.getNamespaceURI().equals( Constants.NS_J2EE )) {
if( !taglibNode.getNamespaceURI().equals( Constants.NS_JAKARTAEE ) ) {
throw new GeneratorException( "Error: " +
tagLibrary.getPathDescription() +
" does not have xmlns=\"" + Constants.NS_JAVAEE + "\"" );
" does not have xmlns=\"" + Constants.NS_JAKARTAEE + "\"" );
}
if( !taglibNode.getLocalName().equals( "taglib" ) ) {
throw new GeneratorException( "Error: " +
Expand Down Expand Up @@ -749,7 +748,7 @@ private void populateTagFileDetailsTagDirective(
name.equals( "description" ) ||
name.equals( "example" ) )
{
element = doc.createElementNS( Constants.NS_JAVAEE, name );
element = doc.createElementNS( Constants.NS_JAKARTAEE, name );
element.appendChild( doc.createTextNode( value ) );
tagFileNode.appendChild( element );
}
Expand All @@ -759,13 +758,13 @@ else if( name.equals( "small-icon" ) ||
NodeList icons = tagFileNode.getElementsByTagNameNS( "*", "icon" );
Element icon;
if( icons.getLength() == 0 ) {
icon = doc.createElementNS( Constants.NS_JAVAEE, "icon" );
icon = doc.createElementNS( Constants.NS_JAKARTAEE, "icon" );
tagFileNode.appendChild( icon );
}
else {
icon = (Element)icons.item( 0 );
}
element = doc.createElementNS( Constants.NS_JAVAEE, name );
element = doc.createElementNS( Constants.NS_JAKARTAEE, name );
element.appendChild( doc.createTextNode( value ) );
icon.appendChild( element );
}
Expand Down Expand Up @@ -805,7 +804,7 @@ private void populateDefault( Document doc, Element parent, String tagName,
String defaultValue )
{
if( findElementValue( parent, tagName ) == null ) {
Element element = doc.createElementNS( Constants.NS_JAVAEE, tagName );
Element element = doc.createElementNS( Constants.NS_JAKARTAEE, tagName );
element.appendChild( doc.createTextNode( defaultValue ) );
parent.appendChild( element );
}
Expand All @@ -824,7 +823,7 @@ private void populateTagFileDetailsAttributeDirective(
Element tagFileNode, Document doc, Directive directive )
{
Iterator attributes = directive.getAttributes();
Element attributeNode = doc.createElementNS( Constants.NS_JAVAEE,
Element attributeNode = doc.createElementNS( Constants.NS_JAKARTAEE,
"attribute" );
tagFileNode.appendChild( attributeNode );
String deferredValueType = null;
Expand All @@ -841,7 +840,7 @@ private void populateTagFileDetailsAttributeDirective(
name.equals( "type" ) ||
name.equals( "description" ) )
{
element = doc.createElementNS( Constants.NS_JAVAEE, name );
element = doc.createElementNS( Constants.NS_JAKARTAEE, name );
element.appendChild( doc.createTextNode( value ) );
attributeNode.appendChild( element );
}
Expand All @@ -864,19 +863,19 @@ else if(name.equals("deferredMethodSignature")) {
}
if(deferredValueType != null) {
Element deferredValueElement =
doc.createElementNS(Constants.NS_JAVAEE, "deferred-value");
doc.createElementNS(Constants.NS_JAKARTAEE, "deferred-value");
attributeNode.appendChild(deferredValueElement);
Element typeElement =
doc.createElementNS(Constants.NS_JAVAEE, "type");
doc.createElementNS(Constants.NS_JAKARTAEE, "type");
typeElement.appendChild(doc.createTextNode(deferredValueType));
deferredValueElement.appendChild(typeElement);
}
if(deferredMethodSignature != null) {
Element deferredMethodElement =
doc.createElementNS(Constants.NS_JAVAEE, "deferred-method");
doc.createElementNS(Constants.NS_JAKARTAEE, "deferred-method");
attributeNode.appendChild(deferredMethodElement);
Element methodSignatureElement =
doc.createElementNS(Constants.NS_JAVAEE, "method-signature");
doc.createElementNS(Constants.NS_JAKARTAEE, "method-signature");
methodSignatureElement.appendChild(
doc.createTextNode(deferredMethodSignature));
deferredMethodElement.appendChild(methodSignatureElement);
Expand Down Expand Up @@ -908,7 +907,7 @@ private void populateTagFileDetailsVariableDirective(
Element tagFileNode, Document doc, Directive directive )
{
Iterator attributes = directive.getAttributes();
Element variableNode = doc.createElementNS( Constants.NS_JAVAEE,
Element variableNode = doc.createElementNS( Constants.NS_JAKARTAEE,
"variable" );
tagFileNode.appendChild( variableNode );
while( attributes.hasNext() ) {
Expand All @@ -923,7 +922,7 @@ private void populateTagFileDetailsVariableDirective(
name.equals( "scope" ) ||
name.equals( "description" ) )
{
element = doc.createElementNS( Constants.NS_JAVAEE, name );
element = doc.createElementNS( Constants.NS_JAKARTAEE, name );
element.appendChild( doc.createTextNode( value ) );
variableNode.appendChild( element );
}
Expand All @@ -950,7 +949,7 @@ private void checkOrAddShortName( TagLibrary tagLibrary, Document doc,
{
String prefix = "prefix" + substitutePrefix;
substitutePrefix++;
Element shortName = doc.createElementNS( Constants.NS_JAVAEE,
Element shortName = doc.createElementNS( Constants.NS_JAKARTAEE,
"short-name" );
shortName.appendChild( doc.createTextNode( prefix ) );
root.appendChild( shortName );
Expand Down Expand Up @@ -999,7 +998,7 @@ private void checkOrAddAttributeType( TagLibrary tagLibrary, Document doc,

// Create <type> element and append to attribute
Element typeElement = doc.createElementNS(
Constants.NS_JAVAEE, "type" );
Constants.NS_JAKARTAEE, "type" );
typeElement.appendChild(
doc.createTextNode( defaultType ) );
attributeElement.appendChild( typeElement );
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/*
* <license>
* Copyright (c) 2003-2004, Sun Microsystems, Inc.
* Copyright (c) 2022 Contributors to the Eclipse Foundation
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
Expand Down Expand Up @@ -183,16 +184,16 @@ protected static Element createRootTaglibNode( Document result,
String path )
{
Element taglibElement = result.createElementNS(
Constants.NS_JAVAEE, "taglib" );
Constants.NS_JAKARTAEE, "taglib" );
// JDK 1.4 does not add xmlns for some reason - add it manually:
taglibElement.setAttributeNS( "http://www.w3.org/2000/xmlns/",
"xmlns", Constants.NS_JAVAEE );
"xmlns", Constants.NS_JAKARTAEE );
taglibElement.setAttributeNS( "http://www.w3.org/2000/xmlns/",
"xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance" );
taglibElement.setAttributeNS(
"http://www.w3.org/2001/XMLSchema-instance",
"xsi:schemaLocation",
Constants.NS_JAVAEE +
Constants.NS_JAKARTAEE +
" http://java.sun.com/xml/ns/javaee/web-jsptaglibrary_2_1.xsd" );
taglibElement.setAttribute( "version", "2.1" );
result.appendChild( taglibElement );
Expand Down

0 comments on commit 77963cd

Please sign in to comment.