commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Diogo Bacelar Quintela (JIRA)" <>
Subject [jira] Updated: (JELLY-213) Generating xml nodes with attributes in diferente namespaces (for schemas..)
Date Sun, 10 Jul 2005 04:39:33 GMT
     [ ]

Diogo Bacelar Quintela updated JELLY-213:

    Attachment: jelly-patch3.patch

Here is patch3 :)

AtributeTag and ElementTag are exactly the same as patch 1
XMLOutput now has a stack of namespaces, and manages the calls to startPrefixMapping and endPrefixMapping.
It passes common testcases and jelly-xml testcases (haven't tried the others :)

It now generates equivalent outputs in both cases (described in above java class TestNS) 
[equivalent means equivalent xml, not necessarly the same order of attributes].

I've included a new tag, that i mentionated some comments above.
A ReplaceNamespaceTag. As it name implies, it replaces all namespaces from one uri to another
in its body (fromURI and toURI properties).
XMLOutput does it job perfectly, again :)


<?xml version="1.0" encoding="UTF-8"?>
<j:jelly xmlns:j="jelly:core" xmlns:x="jelly:xml">
    <x:element URI="${ns}" name="test-node">
        <x:attribute URI="http://apache/testNS" name="test:abc" trim="true">testValue</x:attribute>

        <test-subnode attr="test">
            <test-anotherSubNode />
            <x:element URI="${ns}" name="test-anotherSubNodeAgain">
                <x:attribute URI="${ns}" name="other:abc" trim="true">testValue</x:attribute>

        <x:replaceNamespace toURI="${ns}">
            <test-subnode attr="test">
                <test-anotherSubNode />
                <x:element URI="${ns}" name="test-anotherSubNodeAgain">
                    <x:attribute URI="${ns}" name="other:abc" trim="true">testValue</x:attribute>


When 'ns' is empty/inexistent

<test-node xmlns:test="http://apache/testNS" test:abc="testValue">
<test-subnode attr="test">
<test-anotherSubNodeAgain xmlns:other="" other:abc="testValue">

And when 'ns' if for example 'http://java/ns'

<test-node xmlns:test="http://apache/testNS" xmlns="http://java/ns" test:abc="testValue">
<test-subnode xmlns="" attr="test">
<test-anotherSubNodeAgain xmlns:other="http://java/ns" xmlns="http://java/ns" other:abc="testValue">
<test-subnode attr="test">
<test-anotherSubNodeAgain xmlns:other="http://java/ns" other:abc="testValue">

Usefull ? I'll demonstrate with my example.
I am working in ejb plugin for xdoclet-plugins project, 
the plugins for xdoclet2 project.

plugin.version.isDtd says true if we need an dtd, false, if we are using a schema.
If we are using a dtd, we don't need a namespace, if we are using a schema we need to use
'' as
default namespace. So plugin.version.ns return null when is a dtd, and ''
when its not.
With this 'replaceNamespace' tag we can use the default namespace in jelly script, 
(replacing "" for "" let's it exactly the same :D) for dtd output, and when plugin.version.ns
is all nodes get automatically updated to that namespace.

It will be usefull for xdoclet-plugins, and maybe for other projects.

<?xml version="1.0" encoding="UTF-8"?>
<j:jelly xmlns:j="jelly:core" xmlns:x="jelly:xml" xmlns:jsl="jelly:jsl">
    <j:if test="${plugin.version.isDtd()}">
        <x:doctype name="ejb-jar" publicId="${plugin.version.publicId}" systemId="${plugin.version.systemId}"
trim="true" />
    <x:element URI="${plugin.version.ns}" name="ejb-jar">
        <j:if test="${!plugin.version.isDtd()}">
            <x:attribute URI="${plugin.version.xsiNs}" name="xsi:schemaLocation" trim="true">${plugin.version.schemaLocation}</x:attribute>
            <x:attribute name="version" trim="true">${plugin.version.version}</x:attribute>
        <x:replaceNamespace toURI="${plugin.version.ns}" includeAttributes="true">
                <j:forEach var="class" items="${metadata}">
                    <j:if test="${plugin.shouldGenerate(class)}">

        <j:import uri="org/xdoclet/plugin/ejb/descriptor/entity-beans.jelly" inherit="true"/>
    <!--</ejb-jar> -->

If this patch is usefull as a full (as i think it is), 
i'd be happy to known when it gets added to jelly project, and jelly-xml.

> Generating xml nodes with attributes in diferente namespaces (for schemas..)
> ----------------------------------------------------------------------------
>          Key: JELLY-213
>          URL:
>      Project: jelly
>         Type: Bug
>     Reporter: Diogo Bacelar Quintela
>  Attachments: jelly-patch3.patch, jelly-xml-updated.patch, jelly-xml.patch
> I tried to find some info googling around and in the faq and couldn't find
> the answer, so here it goes.
> I need to generate the following xml (it's a sample off course), to support
> schemas.
> ------------------------------------------------
> <NodeName 
> xmlns="http://blah/bleh" 
> xmlns:xsi="" 
> xsi:schemaLocation="http://blah/blehSchemaLocation">
> <!-- Other content here -->
> </NodeName>
> ------------------------------------------------
> After several tries and some inconsistent behaviour, I thought the following
> jelly excerpt should be close to the solution, however "xml:attribute"
> doesn't support namespaces values.
> ------------------------------------------------
> <j:jelly xmlns:j="jelly:core" xmlns:x="jelly:xml">
> 	<x:element URI="${myns}" name="NodeName">
> 		<x:attribute 
> 			name="xsi:schemaLocation" 
> 			URI="${myxsins}" 
> 			trim="true">
> 		${myschemaloc}
> 		</x:attribute>
> 		<!-- Other content here -->
> 	<x:element>
> </j:jelly>
> Where 
> "myns" is for example http://blah/bleh
> "myschemaloc" is for example http://blah/blehSchemaLocation
> "myxsins" is for example
> ------------------------------------------------
> Is there any known solution for this problem?  Even if working only for
> schemas?

This message is automatically generated by JIRA.
If you think it was sent incorrectly contact one of the administrators:
For more information on JIRA, see:

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message