You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by julien bloit <Ju...@ircam.fr> on 2004/05/11 12:54:32 UTC

xsp : create xml from Array

Hi,
I guess this is a very simple question, but I somehow can't get it working :

I need to create a very simple xml tree from an Array object :

<xsp:logic>
       String labels = <esql:get-string column="Type"/>;
       int i = labels.indexOf('(');
       int f = labels.indexOf(')');
       labels = labels.substring(i+1,f);
       labels = labels.replaceAll("'","");
       String[] labelTab = labels.split(",");
       int longueur = labelTab.length;

        <!-- this doesn't seem to work : -->
       DocumentFragment myLabels = <xsp:element name="labels"/>;
        ...
</xsp:logic>
...

Basically, I just need to create a container element which I can manipulate
later with DOM API to add childs etc...

Here's the error :
org.apache.cocoon.ProcessingException: Language Exception:
org.apache.cocoon.components.language.LanguageException: Error compiling
show_enum_xsp: ERROR 1
(org\apache\cocoon\www\dvdcarte\tests\show_enum_xsp.java): ... labels =
labels.replaceAll("'",""); String[] labelTab = labels.split(","); String un
= labelTab[0]; int longueur = labelTab.length; // start error (lines
426-426) "DocumentFragment cannot be resolved or is not a type"
DocumentFragment myLabels = // end error this.contentHandler.startElement(
"", "labels", ... Line 426, column 0: DocumentFragment cannot be resolved or
is not a type





Thanks for your help!

Julien




---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: xsp : create xml from Array

Posted by julien bloit <Ju...@ircam.fr>.
----- Original Message ----- 
From: "John L. Webber" <Jo...@jentro.com>
To: <us...@cocoon.apache.org>
Sent: Tuesday, May 11, 2004 1:09 PM
Subject: Re: xsp : create xml from Array


> If you just want to have an xml element "labels" generated by the xsp
> for use in the pipeline, you don't need to assign it to any variable at
> all. Simply:
> <labels>
>   <label1/>
>   <label2/>
> </labels>

Well in fact, I need to hold this fragment in
somekind-of-DocumentFragment-variable since I need to recall it later in my
xsp page, using <xsp:expr>somekind-of-DocumentFragment-variable</xsp:expr>.

>
>
> The specific error you got was due to the failure to "import"
> DocumentFragment via xsp:include. You need to have a block like this as
> a top-level element within xsp:page:
>
> <xsp:structure>
>  <xsp:include>org.w3c.dom.DocumentFragment</xsp:include>
> </xsp:structure>
>

Thank you, this gets me on the right tracks, but still this line doesn't
seem to be the right way to initialize a DocumentFragment :
DocumentFragment myLabels = <xsp:element name="labels"/>;

Could someone give me a clue on how to do this, or redirect-to a pertinent
ressource?
Thanks,
Julien



> John
>
> julien bloit wrote:
>
> >Hi,
> >I guess this is a very simple question, but I somehow can't get it
working :
> >
> >I need to create a very simple xml tree from an Array object :
> >
> ><xsp:logic>
> >       String labels = <esql:get-string column="Type"/>;
> >       int i = labels.indexOf('(');
> >       int f = labels.indexOf(')');
> >       labels = labels.substring(i+1,f);
> >       labels = labels.replaceAll("'","");
> >       String[] labelTab = labels.split(",");
> >       int longueur = labelTab.length;
> >
> >        <!-- this doesn't seem to work : -->
> >       DocumentFragment myLabels = <xsp:element name="labels"/>;
> >        ...
> ></xsp:logic>
> >...
> >
> >Basically, I just need to create a container element which I can
manipulate
> >later with DOM API to add childs etc...
> >
> >Here's the error :
> >org.apache.cocoon.ProcessingException: Language Exception:
> >org.apache.cocoon.components.language.LanguageException: Error compiling
> >show_enum_xsp: ERROR 1
> >(org\apache\cocoon\www\dvdcarte\tests\show_enum_xsp.java): ... labels =
> >labels.replaceAll("'",""); String[] labelTab = labels.split(","); String
un
> >= labelTab[0]; int longueur = labelTab.length; // start error (lines
> >426-426) "DocumentFragment cannot be resolved or is not a type"
> >DocumentFragment myLabels = // end error
this.contentHandler.startElement(
> >"", "labels", ... Line 426, column 0: DocumentFragment cannot be resolved
or
> >is not a type
> >
> >
> >
> >
> >
> >Thanks for your help!
> >
> >Julien
> >
> >
> >
> >
> >---------------------------------------------------------------------
> >To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> >For additional commands, e-mail: users-help@cocoon.apache.org
> >
> >
> >
> >
>
> -- 
> ---------------------------------------------------------
>  Jentro Technologies GmbH
>  John L. Webber, Software Development
> ---------------------------------------------------------
>  Rosenheimer Str. 145e     81671 München
>  Tel. +49 89 189 169 80     mailto:John.Webber@jentro.com
>  Fax  +49 89 189 169 99     http://www.jentro.com
> ---------------------------------------------------------
> NOTICE: The information contained in this e-mail is confidential or may
otherwise be legally privileged. It is intended for the named recipient
only. If you have received it in error, please notify us immediately by
reply or by calling the telephone number above and delete this message and
all its attachments without any use or further distribution of its contents.
Please note that any unauthorised review, copying, disclosing or otherwise
making use of the information is strictly prohibited. Thank you.
> ---------------------------------------------------------
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: xsp : create xml from Array

Posted by "John L. Webber" <Jo...@jentro.com>.
If you just want to have an xml element "labels" generated by the xsp 
for use in the pipeline, you don't need to assign it to any variable at 
all. Simply:
<labels>
  <label1/>
  <label2/>
</labels>


The specific error you got was due to the failure to "import" 
DocumentFragment via xsp:include. You need to have a block like this as 
a top-level element within xsp:page:

<xsp:structure>
 <xsp:include>org.w3c.dom.DocumentFragment</xsp:include>
</xsp:structure>

John

julien bloit wrote:

>Hi,
>I guess this is a very simple question, but I somehow can't get it working :
>
>I need to create a very simple xml tree from an Array object :
>
><xsp:logic>
>       String labels = <esql:get-string column="Type"/>;
>       int i = labels.indexOf('(');
>       int f = labels.indexOf(')');
>       labels = labels.substring(i+1,f);
>       labels = labels.replaceAll("'","");
>       String[] labelTab = labels.split(",");
>       int longueur = labelTab.length;
>
>        <!-- this doesn't seem to work : -->
>       DocumentFragment myLabels = <xsp:element name="labels"/>;
>        ...
></xsp:logic>
>...
>
>Basically, I just need to create a container element which I can manipulate
>later with DOM API to add childs etc...
>
>Here's the error :
>org.apache.cocoon.ProcessingException: Language Exception:
>org.apache.cocoon.components.language.LanguageException: Error compiling
>show_enum_xsp: ERROR 1
>(org\apache\cocoon\www\dvdcarte\tests\show_enum_xsp.java): ... labels =
>labels.replaceAll("'",""); String[] labelTab = labels.split(","); String un
>= labelTab[0]; int longueur = labelTab.length; // start error (lines
>426-426) "DocumentFragment cannot be resolved or is not a type"
>DocumentFragment myLabels = // end error this.contentHandler.startElement(
>"", "labels", ... Line 426, column 0: DocumentFragment cannot be resolved or
>is not a type
>
>
>
>
>
>Thanks for your help!
>
>Julien
>
>
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
>For additional commands, e-mail: users-help@cocoon.apache.org
>
>
>  
>

-- 
---------------------------------------------------------
 Jentro Technologies GmbH
 John L. Webber, Software Development
---------------------------------------------------------
 Rosenheimer Str. 145e	    81671 München
 Tel. +49 89 189 169 80     mailto:John.Webber@jentro.com 
 Fax  +49 89 189 169 99     http://www.jentro.com
---------------------------------------------------------
NOTICE: The information contained in this e-mail is confidential or may otherwise be legally privileged. It is intended for the named recipient only. If you have received it in error, please notify us immediately by reply or by calling the telephone number above and delete this message and all its attachments without any use or further distribution of its contents. Please note that any unauthorised review, copying, disclosing or otherwise making use of the information is strictly prohibited. Thank you. 
---------------------------------------------------------


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org