Re: Problem using attributes with xsl:value-of select=/

2009-11-24 Thread Pascal Sancho

Hi,
There is another possible cause: a xsl:template with a higher priority.
What about match=batch[...] or match=parent/batch[...] constructions?
Pascal

J.Pietschmann a écrit :

On 20.11.2009 23:54, Glen Mazza wrote:
  

Hello, I'm having difficulty gettingxsl:value-of select=/  to work with
attributes


...
  

batch myattval=


...
  

   xsl:template match=batch
   fo:blockxsl:value-of select=@myattval//fo:block
   fo:blockxsl:value-of select=./@myattval//fo:block



Both approaches work for me (the first is the canonical one).

I suspect your original problem is somewhat different, common
problems are misspellings, wrong context and namespace confusions.
You might get more help if you cutpaste the actual xml and
xslt code into the mail.

J.Pietschmann



-
To unsubscribe, e-mail: fop-users-unsubscr...@xmlgraphics.apache.org
For additional commands, e-mail: fop-users-h...@xmlgraphics.apache.org



Re: Problem using attributes with xsl:value-of select=/

2009-11-24 Thread J.Pietschmann

On 24.11.2009 03:28, Glen Mazza wrote:

   Fop fop2 = fopFactory.newFop(MimeConstants.MIME_PDF, outStream2);
   Result res2 = new SAXResult(fop2.getDefaultHandler());
   t.transform(rptSource2, res2);


Hmm, Transformers can't be reused, perhaps you should get a new
instance here?

Another possible problem:

atts.addAttribute(, , reportId, , 123);


The method declaration is:
 addAttribute(String uri, String localName, String qName, String type,
   String value)

You are setting the local name to , which may  cause hiccups.
Try any of the following:
 atts.addAttribute(, reportId, reportId, , 123);
 atts.addAttribute(null, reportId, reportId, , 123);
(Actually, I have no idea which one should work, may even be
implementation dependent).

HTH
J.Pietschmann

-
To unsubscribe, e-mail: fop-users-unsubscr...@xmlgraphics.apache.org
For additional commands, e-mail: fop-users-h...@xmlgraphics.apache.org



Re: Problem using attributes with xsl:value-of select=/

2009-11-24 Thread Glen Mazza


J.Pietschmann wrote:
 

Hmm, Transformers can't be reused, perhaps you should get a new
instance here?

 

Oh, I did not know that.  Thanks for the info.


J.Pietschmann wrote:
 
Another possible problem:
 atts.addAttribute(, , reportId, , 123);
 
The method declaration is:
  addAttribute(String uri, String localName, String qName, String type,
String value)
 
You are setting the local name to , which may  cause hiccups.
Try any of the following:
  atts.addAttribute(, reportId, reportId, , 123);
  atts.addAttribute(null, reportId, reportId, , 123);
(Actually, I have no idea which one should work, may even be
implementation dependent).
 

Yes, that was the problem!   Either alternative you have above fixed the
problem for me.

Thanks Joerg!

Glen
-- 
View this message in context: 
http://old.nabble.com/Problem-using-attributes-with-%3Cxsl%3Avalue-of-select%3D%22%22-%3E-tp26451537p26505563.html
Sent from the FOP - Users mailing list archive at Nabble.com.


-
To unsubscribe, e-mail: fop-users-unsubscr...@xmlgraphics.apache.org
For additional commands, e-mail: fop-users-h...@xmlgraphics.apache.org



Re: Problem using attributes with xsl:value-of select=/

2009-11-23 Thread Glen Mazza

Thanks, Joerg--it turns out using Fop command line (Fop -xml ... -xsl ...
-pdf ...) attributes and elements 
copy over perfectly.  It's just within my Java program that I can get only
elements.  I'll need to look more into this issue.

Glen


J.Pietschmann wrote:
 
 Both approaches work for me (the first is the canonical one).
 
 I suspect your original problem is somewhat different, common
 problems are misspellings, wrong context and namespace confusions.
 You might get more help if you cutpaste the actual xml and
 xslt code into the mail.
 
 J.Pietschmann
 

-- 
View this message in context: 
http://old.nabble.com/Problem-using-attributes-with-%3Cxsl%3Avalue-of-select%3D%22%22-%3E-tp26451537p26488126.html
Sent from the FOP - Users mailing list archive at Nabble.com.


-
To unsubscribe, e-mail: fop-users-unsubscr...@xmlgraphics.apache.org
For additional commands, e-mail: fop-users-h...@xmlgraphics.apache.org



Re: Problem using attributes with xsl:value-of select=/

2009-11-23 Thread Glen Mazza

I could use assistance here.  Given an xml such as:

report reportId=123
   animalcat/animal
/report

My embedded FOP transformation is handling elements but not attributes. 
Here is the code as a Nabble attachment:  
http://old.nabble.com/file/p26489602/attributetest.zip attributetest.zip  --
if you have Maven on your machine, mvn clean install exec:exec will
quickly and easily show the problem.  Here is the code within the
attachment:

public class AttributeTest {


private void run() {
   try {
  // works fine -- both animal element and reportId attribute in pdf
  URL fileURL = getClass().getClassLoader().getResource(attr.xml);
  Source rptSource = new StreamSource(fileURL.toString());
  OutputStream outStream = new
java.io.FileOutputStream(1pdfdirect.pdf);
   
  FopFactory fopFactory = FopFactory.newInstance();
  Fop fop = fopFactory.newFop(MimeConstants.MIME_PDF, outStream);
  Result res = new SAXResult(fop.getDefaultHandler());
   
  URL stylesheetURL =
getClass().getClassLoader().getResource(AttributeTest.xsl);
  TransformerFactory factory = TransformerFactory.newInstance();
  Transformer t = factory.newTransformer(new
StreamSource(stylesheetURL.toString()));
  t.transform(rptSource, res);
  outStream.close();
  
  // does not work -- has animal element but not reportId attribute
in pdf
  Source rptSource2 = new SAXSource(new ReportXMLBuilder(), new
EmptyInputSource());
  OutputStream outStream2 = new
java.io.FileOutputStream(2pdfViaReader.pdf);

  Fop fop2 = fopFactory.newFop(MimeConstants.MIME_PDF, outStream2);
  Result res2 = new SAXResult(fop2.getDefaultHandler());
  t.transform(rptSource2, res2);
  outStream2.close();
  
  // but oddly, this *does* work -- keeps reportId attribute
  Source rptSource3 = new SAXSource(new ReportXMLBuilder(), new
EmptyInputSource());
  Transformer t2 = factory.newTransformer();  
  Result res3 = new StreamResult(3xmloutput.xml); // has reportId
attribute
  t2.transform(rptSource3, res3);
  
   } catch (Exception e) {
  e.printStackTrace(System.out);
   }
}

// AbstractXMLBuilder is here: http://tinyurl.com/ye4c39h
public static class ReportXMLBuilder extends AbstractXMLBuilder {
   public void parse(InputSource input) throws IOException, SAXException
{
   handler.startDocument();
   AttributesImpl atts = new AttributesImpl();
   atts.addAttribute(, , reportId, , 123);
   handler.startElement(report, atts);
   handler.element(animal, cat);
   handler.endElement(report);
   handler.endDocument();
   }
}
  
...
}

Can anyone see what I'm doing wrong?

Thanks,
Glen



J.Pietschmann wrote:
 
 Both approaches work for me (the first is the canonical one).
 
 I suspect your original problem is somewhat different, common
 problems are misspellings, wrong context and namespace confusions.
 You might get more help if you cutpaste the actual xml and
 xslt code into the mail.
 
 J.Pietschmann
 

-- 
View this message in context: 
http://old.nabble.com/Problem-using-attributes-with-%3Cxsl%3Avalue-of-select%3D%22%22-%3E-tp26451537p26489602.html
Sent from the FOP - Users mailing list archive at Nabble.com.


-
To unsubscribe, e-mail: fop-users-unsubscr...@xmlgraphics.apache.org
For additional commands, e-mail: fop-users-h...@xmlgraphics.apache.org



Re: Problem using attributes with xsl:value-of select=/

2009-11-21 Thread J.Pietschmann

On 20.11.2009 23:54, Glen Mazza wrote:

Hello, I'm having difficulty gettingxsl:value-of select=/  to work with
attributes

...

batch myattval=

...

   xsl:template match=batch
   fo:blockxsl:value-of select=@myattval//fo:block
   fo:blockxsl:value-of select=./@myattval//fo:block


Both approaches work for me (the first is the canonical one).

I suspect your original problem is somewhat different, common
problems are misspellings, wrong context and namespace confusions.
You might get more help if you cutpaste the actual xml and
xslt code into the mail.

J.Pietschmann

-
To unsubscribe, e-mail: fop-users-unsubscr...@xmlgraphics.apache.org
For additional commands, e-mail: fop-users-h...@xmlgraphics.apache.org



Problem using attributes with xsl:value-of select=/

2009-11-20 Thread Glen Mazza

Hello, I'm having difficulty getting xsl:value-of select=/ to work with
attributes--it must be something obvious but I can't figure out the problem. 
(I'm using FOP 0.95-1.)

For this XML snippet:

batch myattval=
   aaadog/aaa
   bbbcat/bbb
...

and this XSL template:

  xsl:template match=batch
  fo:blockxsl:value-of select=@myattval//fo:block
  fo:blockxsl:value-of select=./@myattval//fo:block
  fo:blockxsl:value-of select=./myattval//fo:block
  fo:blockxsl:value-of select=myattval//fo:block
  fo:blockxsl:value-of select=./aaa//fo:block
  fo:blockxsl:value-of select=./bbb//fo:block
   

I can get aaa and bbb to output but I cannot get myattval to appear.  I
would think the first and second would be correct, but none of the four
attempts above are working for myattval.  Can anybody see what I'm doing
wrong?

Thanks,
Glen

-- 
View this message in context: 
http://old.nabble.com/Problem-using-attributes-with-%3Cxsl%3Avalue-of-select%3D%22%22-%3E-tp26451537p26451537.html
Sent from the FOP - Users mailing list archive at Nabble.com.


-
To unsubscribe, e-mail: fop-users-unsubscr...@xmlgraphics.apache.org
For additional commands, e-mail: fop-users-h...@xmlgraphics.apache.org