Help with XML and DOM Classes

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Help with XML and DOM Classes

Adrian Crum
I'm working on the entity engine model classes to include support for accessing the description
elements during run time. I've run into a problem I can't figure out.

Using the following entity definition:

<entity entity-name="Content" package-name="org.ofbiz.content.content" title="Content Entity">
   <field name="ownerContentId" type="id"><description>Used for permissions
checking</description></field>
   ...
</entity>

I have the description Element in code, but I can't seem to get the text of the description:

NodeList descriptionList = fieldElement.getElementsByTagName("description");
for (int i = 0; i < descriptionList.getLength(); i++) {
     Element element = (Element) descriptionList.item(i);
     if (element.getNodeValue() != null) {
         this.description = element.getNodeValue();
     }
}

I've tried getNodeValue() and getTextContent(), but both return null.

Any ideas?

-Adrian


Reply | Threaded
Open this post in threaded view
|

Re: Help with XML and DOM Classes

Adrian Crum
Never mind - I discovered UtilXml.childElementValue(...)

Problem solved.

Adrian Crum wrote:

> I'm working on the entity engine model classes to include support for
> accessing the description elements during run time. I've run into a
> problem I can't figure out.
>
> Using the following entity definition:
>
> <entity entity-name="Content" package-name="org.ofbiz.content.content"
> title="Content Entity">
>   <field name="ownerContentId" type="id"><description>Used for
> permissions checking</description></field>
>   ...
> </entity>
>
> I have the description Element in code, but I can't seem to get the text
> of the description:
>
> NodeList descriptionList =
> fieldElement.getElementsByTagName("description");
> for (int i = 0; i < descriptionList.getLength(); i++) {
>     Element element = (Element) descriptionList.item(i);
>     if (element.getNodeValue() != null) {
>         this.description = element.getNodeValue();
>     }
> }
>
> I've tried getNodeValue() and getTextContent(), but both return null.
>
> Any ideas?
>
> -Adrian
>
>
>

Reply | Threaded
Open this post in threaded view
|

Re: Help with XML and DOM Classes

Jacopo Cappellato
In reply to this post by Adrian Crum
Adrian,

this is probably a bit off topic, but recently (while working on the
Business Intelligence application) I've completed some support to access
descriptions on entities and views' fields.
I don't remember the details (and I'm not even sure you are trying to do
something similar) but you may have a look at the way metadata are
retrived in the bsh script:

http://svn.apache.org/repos/asf/ofbiz/trunk/specialpurpose/bi/webapp/bi/WEB-INF/actions/reportbuilder/getStarSchemaFields.bsh

Jacopo



Adrian Crum wrote:

> I'm working on the entity engine model classes to include support for
> accessing the description elements during run time. I've run into a
> problem I can't figure out.
>
> Using the following entity definition:
>
> <entity entity-name="Content" package-name="org.ofbiz.content.content"
> title="Content Entity">
>   <field name="ownerContentId" type="id"><description>Used for
> permissions checking</description></field>
>   ...
> </entity>
>
> I have the description Element in code, but I can't seem to get the text
> of the description:
>
> NodeList descriptionList =
> fieldElement.getElementsByTagName("description");
> for (int i = 0; i < descriptionList.getLength(); i++) {
>     Element element = (Element) descriptionList.item(i);
>     if (element.getNodeValue() != null) {
>         this.description = element.getNodeValue();
>     }
> }
>
> I've tried getNodeValue() and getTextContent(), but both return null.
>
> Any ideas?
>
> -Adrian
>

Reply | Threaded
Open this post in threaded view
|

Re: Help with XML and DOM Classes

Adrian Crum
Jacopo,

Yes, that is exactly what I am working on. Did you notice that

String description = field.getDescription();

doesn't work?

-Adrian

Jacopo Cappellato wrote:

> Adrian,
>
> this is probably a bit off topic, but recently (while working on the
> Business Intelligence application) I've completed some support to access
> descriptions on entities and views' fields.
> I don't remember the details (and I'm not even sure you are trying to do
> something similar) but you may have a look at the way metadata are
> retrived in the bsh script:
>
> http://svn.apache.org/repos/asf/ofbiz/trunk/specialpurpose/bi/webapp/bi/WEB-INF/actions/reportbuilder/getStarSchemaFields.bsh 
>
>
> Jacopo
>
>
>
> Adrian Crum wrote:
>
>> I'm working on the entity engine model classes to include support for
>> accessing the description elements during run time. I've run into a
>> problem I can't figure out.
>>
>> Using the following entity definition:
>>
>> <entity entity-name="Content" package-name="org.ofbiz.content.content"
>> title="Content Entity">
>>   <field name="ownerContentId" type="id"><description>Used for
>> permissions checking</description></field>
>>   ...
>> </entity>
>>
>> I have the description Element in code, but I can't seem to get the
>> text of the description:
>>
>> NodeList descriptionList =
>> fieldElement.getElementsByTagName("description");
>> for (int i = 0; i < descriptionList.getLength(); i++) {
>>     Element element = (Element) descriptionList.item(i);
>>     if (element.getNodeValue() != null) {
>>         this.description = element.getNodeValue();
>>     }
>> }
>>
>> I've tried getNodeValue() and getTextContent(), but both return null.
>>
>> Any ideas?
>>
>> -Adrian
>>
>
>

Reply | Threaded
Open this post in threaded view
|

Re: Help with XML and DOM Classes

Jacopo Cappellato
It seems to be working here:

https://localhost:8443/bi/control/ReportBuilderSelectStarSchema

submit the form and the next screen will show meta data info (using the
script)

Jacopo


Adrian Crum wrote:

> Jacopo,
>
> Yes, that is exactly what I am working on. Did you notice that
>
> String description = field.getDescription();
>
> doesn't work?
>
> -Adrian
>
> Jacopo Cappellato wrote:
>
>> Adrian,
>>
>> this is probably a bit off topic, but recently (while working on the
>> Business Intelligence application) I've completed some support to
>> access descriptions on entities and views' fields.
>> I don't remember the details (and I'm not even sure you are trying to
>> do something similar) but you may have a look at the way metadata are
>> retrived in the bsh script:
>>
>> http://svn.apache.org/repos/asf/ofbiz/trunk/specialpurpose/bi/webapp/bi/WEB-INF/actions/reportbuilder/getStarSchemaFields.bsh 
>>
>>
>> Jacopo
>>
>>
>>
>> Adrian Crum wrote:
>>
>>> I'm working on the entity engine model classes to include support for
>>> accessing the description elements during run time. I've run into a
>>> problem I can't figure out.
>>>
>>> Using the following entity definition:
>>>
>>> <entity entity-name="Content"
>>> package-name="org.ofbiz.content.content" title="Content Entity">
>>>   <field name="ownerContentId" type="id"><description>Used for
>>> permissions checking</description></field>
>>>   ...
>>> </entity>
>>>
>>> I have the description Element in code, but I can't seem to get the
>>> text of the description:
>>>
>>> NodeList descriptionList =
>>> fieldElement.getElementsByTagName("description");
>>> for (int i = 0; i < descriptionList.getLength(); i++) {
>>>     Element element = (Element) descriptionList.item(i);
>>>     if (element.getNodeValue() != null) {
>>>         this.description = element.getNodeValue();
>>>     }
>>> }
>>>
>>> I've tried getNodeValue() and getTextContent(), but both return null.
>>>
>>> Any ideas?
>>>
>>> -Adrian
>>>
>>
>>

Reply | Threaded
Open this post in threaded view
|

Re: Help with XML and DOM Classes

Adrian Crum
Ah. That's because you're using ModelAlias. ModelField.getDescription() doesn't work.

I should have a patch ready in a few hours.


Jacopo Cappellato wrote:

> It seems to be working here:
>
> https://localhost:8443/bi/control/ReportBuilderSelectStarSchema
>
> submit the form and the next screen will show meta data info (using the
> script)
>
> Jacopo
>
>
> Adrian Crum wrote:
>
>> Jacopo,
>>
>> Yes, that is exactly what I am working on. Did you notice that
>>
>> String description = field.getDescription();
>>
>> doesn't work?
>>
>> -Adrian
>>
>> Jacopo Cappellato wrote:
>>
>>> Adrian,
>>>
>>> this is probably a bit off topic, but recently (while working on the
>>> Business Intelligence application) I've completed some support to
>>> access descriptions on entities and views' fields.
>>> I don't remember the details (and I'm not even sure you are trying to
>>> do something similar) but you may have a look at the way metadata are
>>> retrived in the bsh script:
>>>
>>> http://svn.apache.org/repos/asf/ofbiz/trunk/specialpurpose/bi/webapp/bi/WEB-INF/actions/reportbuilder/getStarSchemaFields.bsh 
>>>
>>>
>>> Jacopo
>>>
>>>
>>>
>>> Adrian Crum wrote:
>>>
>>>> I'm working on the entity engine model classes to include support
>>>> for accessing the description elements during run time. I've run
>>>> into a problem I can't figure out.
>>>>
>>>> Using the following entity definition:
>>>>
>>>> <entity entity-name="Content"
>>>> package-name="org.ofbiz.content.content" title="Content Entity">
>>>>   <field name="ownerContentId" type="id"><description>Used for
>>>> permissions checking</description></field>
>>>>   ...
>>>> </entity>
>>>>
>>>> I have the description Element in code, but I can't seem to get the
>>>> text of the description:
>>>>
>>>> NodeList descriptionList =
>>>> fieldElement.getElementsByTagName("description");
>>>> for (int i = 0; i < descriptionList.getLength(); i++) {
>>>>     Element element = (Element) descriptionList.item(i);
>>>>     if (element.getNodeValue() != null) {
>>>>         this.description = element.getNodeValue();
>>>>     }
>>>> }
>>>>
>>>> I've tried getNodeValue() and getTextContent(), but both return null.
>>>>
>>>> Any ideas?
>>>>
>>>> -Adrian
>>>>
>>>
>>>
>
>